lua-users home
lua-l archive

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

I don't know, but I can guess at a couple reasons:

1. It's friendlier toward interactive work.

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

Note that Scheme handles things in the same way as Lua.


on 8/4/05 11:04 AM, Uli Kusterer at wrote:

> Hi,
> if I understood this correctly, the way variables work in Lua is
> that they are global by default, and you explicitly declare those
> local that you want to be thus. Is there any place where I can find
> information on why it was designed this way, which is pretty much the
> opposite of the major languages?
> So far I thought it was safer if variables are local by default, so
> code can't accidentally change another object's variables (e.g.
> during a recursive call).
> Cheers,
> -- M. Uli Kusterer