On Wed, 2 Aug 2006, Chad Perrin wrote: > On Wed, Aug 02, 2006 at 05:12:02AM +0900, ara.t.howard / noaa.gov wrote: >> On Wed, 2 Aug 2006, Chad Perrin wrote: >>> >>> Wait . . . are you serious? Ruby is using dynamic scope here? Ugh. >> >> no. >> >> def x >> puts a >> end >> >> is __lexical__ scoping. not dynamic. > > It's not lexical scoping if that "a" variable is separate from the "a" > variable in the enclosing scope. yes. it is, because there is no 'a' in the enclosing dynamic scope: harp:~ > cat a.rb a = 42 def m() p a end m harp:~ > ruby a.rb a.rb:4:in `m': undefined local variable or method `a' for main:Object (NameError) from a.rb:6 you have to understand that ruby doesn't always use one method of scoping - sometimes it's dynamic and sometimes it's lexical. -a -- we can never obtain peace in the outer world until we make peace with ourselves. - h.h. the 14th dali lama