------ art_17050_15210613.1154310956653 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline So to clarify... in 1.8, constant scoping within a block is decided at compile time, and so is scoped in the scope where the block is created. In this case, that means all constants within a block, even a module_eval block will be defined at the level at which module_eval was called. in 1.9, constant scoping is determined at runtime, so this example would scope the constant within the Foo module, and defined? BAZ at the top level will return nil. Is that about right? On 7/30/06, Yukihiro Matsumoto <matz / ruby-lang.org> wrote: > > Hi, > > In message "Re: Inconsistency in scoping during module_eval?" > on Sun, 30 Jul 2006 20:39:08 +0900, "Charles O Nutter" < > headius / headius.com> writes: > > |Why does this: > | > |class Foo > | BAZ > |end > | > |produce a different result than this: > | > |class Foo > |end > |Foo.module_eval { > | BAZ > |} > > Constant assignments follows static scoping in 1.8. You have to use > const_set method or switch to 1.9. > > > matz. > > -- Contribute to RubySpec! @ www.headius.com/rubyspec Charles Oliver Nutter @ headius.blogspot.com Ruby User @ ruby.mn JRuby Developer @ www.jruby.org Application Architect @ www.ventera.com ------ art_17050_15210613.1154310956653--