From: Thomas Sawyer Date: 2011-07-06T00:09:27+09:00 Subject: [ruby-core:37800] [Ruby 1.9 - Feature #3768] Constant Lookup doesn't work in a subclass of BasicObject Issue #3768 has been updated by Thomas Sawyer. @jeremy You make a good case. My general sense of it is YAGNI, but I can't completely rule it out. Who knows, maybe someone will have need of a very clever way to resolve constants for their own classes. But, I think we are perilously close here to that "well-chosen-line" that separates the dependable static language from the convenient dynamic one. If a work around can be found for my eval case, as given above, then I am perfectly happy to concede this issue. I do want to make one point clear however, as I think your explanation could be interpreted as making a false equivalency. To point, constant look-up and method look-up should not be confused for analogous features. They are in fact quite different. Method look-up operates through the class-hierarchy, while constants are a strange hybrid, which primarily operate through the namespace, but also include the class hierarchy, basically as a matter of convenience. So I still maintain that constant look-up should ultimately terminate at the toplevel (even if BasicObject ignores this). Just as I also am certain that toplevel method definitions really should not be polluting the Object class. ---------------------------------------- Feature #3768: Constant Lookup doesn't work in a subclass of BasicObject http://redmine.ruby-lang.org/issues/3768 Author: Thomas Sawyer Status: Rejected Priority: Normal Assignee: Yukihiro Matsumoto Category: lib Target version: =begin ruby-1.9.2-p0 > module M ruby-1.9.2-p0 ?> end => nil ruby-1.9.2-p0 > class X < BasicObject ruby-1.9.2-p0 ?> include M ruby-1.9.2-p0 ?> end NameError: uninitialized constant X::M from (irb):4:in `' from (irb):3 from /home/trans/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `
' =end -- http://redmine.ruby-lang.org