lua-users home
lua-l archive

Re: possible bug

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


* On Sat Mar 30 17:33:00 +0100 2013, Mason Mackaman wrote:
 
> why does 'f()' remove all entries of 'a'? Is that something I coded 
> into 'f()' or is that something Lua does with functions?
Sorry, I wasn't quite clear:
The culprit is in the line
 local newset,cloneset={},set
which is doing a multiple assignment on the locals newset and cloneset.
You probably ment to say:
 local nweset
 local cloneset = {}
 local set
but what your code does is:
 local newset = {}
 local cloneset = set
f() removes all entries from cloneset, which is a now a reference to a,
thus leaving the table a empty.
Coming from C this one is indeed tricky, I admit it happend to me a few
times as well.
-- 
:wq
^X^Cy^K^X^C^C^C^C

AltStyle によって変換されたページ (->オリジナル) /