From: Brian Candler Date: 2011-03-28T17:55:08+09:00 Subject: Re: How to get the value of a singleton class? Robert Dober wrote in post #989410: > On Sat, Mar 26, 2011 at 1:15 PM, Aaron D. Gifford > wrote: >> On Sat, Mar 26, 2011 at 4:44 AM, Robert Dober wrote: > >> That just seems right. > > I do not really have a problem with this. However I feel that it is > really not for the language to decide if I want to do this or not. The > more restrictive way does not give me the opportunity to use closures > easily in my classes while it would still allow *not* to use them. BTW > I am quite convinced that this > is not a design choice I think it *is* a design choice, because of the local variable/method ambiguity. If "class" and "def" did not start a new scope, then a bareword like "x" *might* be a local variable within a closure. It would be extremely difficult to tell; you'd have to read the entire program source code back to the beginning of the file (assuming that 'load' and 'require' started a new scope, otherwise it would be completely impossible). With the current rules, given some code like ... lots of previous stuff def foo x end you can tell by inspection of method foo alone that x *must* be a method call within foo; it's definitely not a local variable. -- Posted via http://www.ruby-forum.com/.