lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Aug 4, 2005, at 20:15:39, Mark Hamburg wrote:
I don't know, but I can guess at a couple reasons:

1. It's friendlier toward interactive work.
 Well, I'm a big fan of HyperTalk, which solved the problem for  
interactivity by simply being able to run the same code in a  
different "local" scope. I.e. usually, local variables really were  
local, but if you used the interactive command prompt ("message  
box"), the local scope *was* the global scope, and every variable you  
used automatically became global.
2. You still need declarations for locals to recognize where the scope
starts for a variable. So, the real question is why no declaration for
globals as opposed to why a declaration is needed for locals. For that, see
1.

Note that Scheme handles things in the same way as Lua.
 I see how scoping can be an issue. Though I personally favor the  
opinion that, if you use scope "hiding" inside the same function,  
it's an unprettyness that should be avoided as it makes the code  
harder to read. Continuing from there, I'd want my compiler to not  
allow this, in the interest of easing debugging.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de