[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Global by default
- From: Steve Litt <slitt@...>
- Date: Wed, 13 Feb 2013 03:51:55 -0500
On Tue, 12 Feb 2013 20:50:03 +0100
David Olofson <david@olofson.net> wrote:
> On Tue, Feb 12, 2013 at 7:30 PM, Dirk Laurie <dirk.laurie@gmail.com>
> wrote:
>
> > 2013/2/12 Peter Slížik <peter.slizik@gmail.com>:
> > > Okay, here's the new thread I announced a while ago...
> > >
> > > Lua-users wiki cites Roberto's words:
> > >
> > > "Local by default is wrong. Maybe global by default is also
> > > wrong, [but]
> > the
> > > solution is not local by default."
> > >
> > > Could anybody who understands Lua innards elaborate?
> > >
> >
> > One possible reason might be that Lua only allows so many
> > local variables, 200 I think, the number must fit into one byte
> > otherwise the whole VM needs to be redesigned. Whereas
> > the number of global variables is for all practical purposes
> > unlimited.
> >
>
> IIRC, local variables are implemented over VM registers (similar to
> how a native language uses CPU registers and/or the stack), so the
> limit would be per-function. Not a problem normally, that is.
That's a whole lot better than per program. I didn't believe that any
language would be limited to 256 local vars per program.
Next question: Is it per function, or per function invocation. In other
words, if I recursively called a function with 10 local variables,
would it break when I went 26 recursions deep?
SteveT