From: dblack@... Date: 2003-08-13T20:39:28+09:00 Subject: Re: Nested class/module namespace Hi -- On Wed, 13 Aug 2003, Gavin Sinclair wrote: > Nathaniel has identified a difference between the two cases above when one > tries to access a constant, say X::C (which is not defined in the above > code). > > If there is a difference, then there must be a difference in the > "execution context". To my way of thinking, the only thing that should be > important in an execution context is the value of "self". If that is not > the case, we need an explanation, and probably a justification. At the > moment, I think the elegance of Ruby is being stretched a bit. Keep in mind, though, that this isn't the only such situation in Ruby. See my previous post with the class_eval example; also, here's another situation where 'self' can be the same but visibility of constants is different: class C X=1 end c = C.new class << c def a; p self; p X; end end def c.b; p self; p X; end c.a c.b # error: unknown constant X (Having several such situations may not make it more attractive to you, but I just wanted to get this one on the radar.) David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav