[#109207] [Ruby master Feature#18915] New error class: NotImplementedYetError or scope change for NotImplementedYet — Quintasan <noreply@...>
Issue #18915 has been reported by Quintasan (Michał Zając).
18 messages
2022/07/14
[ruby-core:109347] [Ruby master Feature#18930] Officially deprecate class variables
From:
"byroot (Jean Boussier)" <noreply@...>
Date:
2022-07-28 07:21:02 UTC
List:
ruby-core #109347
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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>