[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Globals vs. Locals
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 04 Aug 2005 11:15:39 -0700
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
1.
Note that Scheme handles things in the same way as Lua.
Mark
on 8/4/05 11:04 AM, Uli Kusterer at witness.of.teachtext@gmx.net 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
> http://www.zathras.de
>
>