On Tue, Aug 01, 2006 at 12:54:58PM +0900, Logan Capaldo wrote:
> 
> I imagine it was to avoid having to declare local variables. e.g.:
> 
> a = 1
> 
> def add_two
>   a = 2
>   return a + n
> end
> 
> 
> ... hundred of lines of code later ...
> 
> def b
>   puts a
> end
> 
> Now I imagine when our hypothetical programmer wrote b he expected it  
> to always print the value of the top-level a.
> 
> OTOH when he wrote add_two he was expecting a to behave as a local  
> variable.

This is one of the reasons that explicit scoping declarations are
generally a good idea: testing code with explicit lexical scoping
declarations will quickly tell you exactly what you screwed up, and
using local dynamic declarations will actually do what you surmise the
hypothetical programmer must have assumed.  Autovivification is great,
as long as you use it with conscious intent for good reasons rather than
just because you're lazy.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
This sig for rent:  a Signify v1.14 production from http://www.debian.org/