lua-users home
lua-l archive

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


this is a garbage collected language.. and dinamic, so a think this is
pretty much consistent behaviour for that scenario..

if you wanna write machine generated source code for instance, this is
even a feature.. since you wouldnt bother to create new symbols :)

and as you've saw.. the runtime didnt let you blow up the stack(and
memory) with the repeated redeclaration.. so i think that is pretty
much "foolproof" to me. :)


On Thu, Jun 9, 2011 at 1:33 PM, Dirk Laurie <dpl@sun.ac.za> wrote:
> On Thu, Jun 09, 2011 at 05:57:21PM +0200, Andreas Falkenhahn wrote:
>>
>>
>> function myfunc()
>> local a, b = 1,2
>> end
>>
>> and repeat the line "local a, b = 1,2" over 100 times in the function, I get
>> the following error:
>> input:102: function at line 1 has more than 200 local variables
>>
>> I'm wondering whether this is intended behaviour because actually, I'm only using
>> two variables named 'a' and 'b'. They are all placed in the same scope so I don't
>> quite understand why Lua creates 200 variables from these two. Because the
>> initializations occur always in the same scope, Lua wouldn't have to store 200
>> variables on the stack but it could simply work with two. Any explanations for
>> this behaviour?
>
> The code for `local a` does not check whether `a` already exists.
> It's the familiar Lua trade-off: speed is more important than being
> foolproof, because Lua programmers by definition are not fools.
>
> Dirk
>
>
>