Comment on Rubinius X, an experiment in modernizing RubyComments−comex12yGlobal VariablesGone. Period.That's pretty extreme. What is supposed to replace them?−lobster_johnson12yIt's not really extreme. You can, and should, easily provide globals through attributes on classes and modules (which are globals themselves): module Foot @size = 10 class << self attr_accessor :size end end Foot.size = 8 ActiveSupport gives you "mattr_accessor" and "class_attribute" to accomplish the same thing with less code.In my opinion, class/module-level attributes are useful enough that it ought to be provided by the language itself.Edit: Come to think of it, most people, that I have seen, use globals to set constants. That currently has perfectly good syntax: module Foot SIZE = 10 end print Foot::SIZE−cheald12ySans ActiveSupport, you can achieve the same things by just opening class/module eigenclass: module Foo class << self attr_accessor :bar end end Foo.bar = "baz"−lobster_johnson12ySure, but wasn't that exactly what I wrote in my first example?−cheald12yOy, it is. Sorry; my brain is apparently missing its reading comprehension hat today.
Comments
That's pretty extreme. What is supposed to replace them?
It's not really extreme. You can, and should, easily provide globals through attributes on classes and modules (which are globals themselves):
ActiveSupport gives you "mattr_accessor" and "class_attribute" to accomplish the same thing with less code.In my opinion, class/module-level attributes are useful enough that it ought to be provided by the language itself.
Edit: Come to think of it, most people, that I have seen, use globals to set constants. That currently has perfectly good syntax:
Sans ActiveSupport, you can achieve the same things by just opening class/module eigenclass:
Sure, but wasn't that exactly what I wrote in my first example?
Oy, it is. Sorry; my brain is apparently missing its reading comprehension hat today.