From: David Garamond Date: 2004-02-26T23:55:23+09:00 Subject: Re: Why don't $global and @instance variables need *initialization*? David Garamond wrote: > ts wrote: > >>>>>>> "D" == David Garamond writes: >> >> D> NameError: undefined local variable or method `a' for main:Object >> ^^^^^^^^^^^^^^^^^^^^^^^^ >> >> The message is important : ruby don't know if it's a variable or a >> method >> and can't initialize it. > > I see. I thought Ruby's intention was to protect someone from making a > stupid mistake of using uninitialized variables (ala Python). But then I > remember Ruby has the -w switch, so I guess Ruby never enforces this and > just gives a warning. Btw, what do people think of adding the following system hooks in Ruby: Kernel::unitialized_global_variable_accessed Kernel::unitialized_instance_variable_accessed which can be used to implement the behaviour for instance and global variables (i.e. raising NameError), but without breaking the current behaviour. -- dave