[ruby-core:120126] [Ruby master Feature#18930] Officially deprecate class variables

Issue #18930 has been updated by Dan0042 (Daniel DeLorme). I'm still against deprecating, either soft or hard, but I believe the errors could be improved. ```ruby class A def self.foo p @@foo ||= rand end end class B < A p @@foo = 2 end B.foo ``` In this code, the @@foo variable is overtaken but the "overtaken" error isn't triggered because even though the `foo` method is invoked on B, it was defined in A. If this could be improved to raise an error, I believe it might relieve some of the confusion over class variables. ---------------------------------------- Feature #18930: Officially deprecate class variables https://bugs.ruby-lang.org/issues/18930#change-110877 * Author: Eregon (Benoit Daloze) * Status: Rejected ---------------------------------------- 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/
participants (1)
-
Dan0042 (Daniel DeLorme)