From: Caleb Clausen Date: 2010-06-08T00:42:21+09:00 Subject: Re: Singleton classes and Namespce On 6/7/10, Robert Klemme wrote: > 2010/6/7 Caleb Clausen : >> Ah, but constant lookup is supposed to check the ancestors if the >> constant is not found in the scope. M should be among the ancestors of >> o's singleton class, shouldn't it? > > It does but you are not in the scope of the singleton class. Rather > you are in the toplevel (or any other) scope when you do "def o.x; X; > end". >> I guess the key point to understand is that for singleton methods, >> container is the (static) module of class enclosing the singleton >> method, NOT the singleton class that they affect. > > Not sure I can follow you here. IMHO the key point is to understand > that it is a difference whether you open a scope (class, module) or > access the scope from the outside: Sorry, I meant 'module or class', not 'module of class'. Basically, I'm agreeing with what you said just above. It just took me a little longer to get to the same point of understanding about constant lookup that you were at. (Like I said: constant lookup is confusing.)