From: Intransition Date: 2009-12-31T01:27:13+09:00 Subject: Re: Using #include at the instance level? On Dec 30, 4:34 am, Robert Klemme wrote: > Thanks for the test case!  It never occurred to me to do a const > lookup in a class defined with a class body so I never stumbled across > this.  I did a bit of research and this is what I found: > > Statement from Matz about the change: "In 1.8, constant uses lexical > look-up, even within the block given to instance_eval().  We changed > this behavior in 1.9 to simplify things."http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/181646 > > Found viahttp://eigenclass.org/hiki/withdrawn-experimental-ruby-features > - I am not so sure about the "experimental" status of this though - > maybe this is due to the last update date of the page in 2007... > > Adam Gardner also made an interesting observation about the difference > between const_get and direct constant lookup:http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/333677 > (I have changed the test output to easier interpret it. See attachment.) > > There's also this discussionhttp://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-core/25865?2... > > And thishttp://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/334016?... > > To sum it up: Ruby 1.9 changed lookup rules from lexical (aka static) > to dynamic.  IMHO this explains the observed different behavior. > Thanks again for poking. Very helpful. Thanks for going to all the trouble, Robert. I now see the issue I am facing laser clear.