From: Xavier Noria Date: 2007-11-16T19:24:13+09:00 Subject: Re: constant name resolution and module_eval On Nov 16, 2007, at 11:14 AM, Robert Dober wrote: > M.module_eval <<-EOS > def self.const; C end > D = 1 > EOS > > puts M.const > puts M::D # -> 1 >> >> But surprisingly module_eval defines M.const, and does _not_ define >> M::D. I know module_eval sees the surrounding scope and that allows >> some idioms a regular module reopening does not, but I need yet to >> put >> the pieces together for constants. > No it is not module_eval that sees the surrounding scope it is the > closure, as you can verify with the string > form of module_eval. > I did not know that behavior for constants either, very interesting. Good point! And with that alternative M.const gives "M" instead of "Object" as well. Very interesting. -- fxn