From: "byroot (Jean Boussier)" Date: 2022-07-28T07:21:02+00:00 Subject: [ruby-core:109347] [Ruby master Feature#18930] Officially deprecate class variables Issue #18930 has been updated by byroot (Jean Boussier). Even though I don't remember adding any new class variable in the last half decade, I'm not sure we can deprecate them, as IMO deprecations should be actionable, and some of these may not be. I think the main use case for class variables that is still legitimate is for class level configuration without inheritance, e.g. ```ruby class SomeThingNeverInherited class << self def some_config=(value) @@some_config = value end end def do_thing if @@some_config do_one_thing else do_another_thing end end end ``` If you deprecate class variables, the only way to do this is to publicize that state, so that the instance can access it with `self.class.some_config`. That's not a huge deal, but still feels wrong. I know it's a big ask, but I really feel a better solution would be to introduce true class variables with an usable semantic (like Python). ---------------------------------------- Feature #18930: Officially deprecate class variables https://bugs.ruby-lang.org/issues/18930#change-98492 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal ---------------------------------------- Ruby's class variables are very confusing, and it seem many people agree they should be avoided (#18927). How about we deprecate them officially? Concretely: * Mention in the documentation that class variables are deprecated and should be avoided/should not be used. * Add a parse-time deprecation warning, now that we only see those with `Warning[:deprecation] = true` it seems reasonable to add. -- https://bugs.ruby-lang.org/ Unsubscribe: