[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Writing Iterator in C
- From: "Peter Cawley" <lua@...>
- Date: Wed, 31 Dec 2008 15:33:14 +0000
Well, it shouldn't. Modifying the control variables of a for loop only affects the copy of that variable within the for loop body - not the variable which is passed back into the iteration function (similarly with a numeric for, the control variable is shadowed within the loop body).
Note that p (the control variable) is changed in the body
of the for loop, and this works fine in pure Lua.
Also odd is your use of brackets in Lua return statements. This is invalid in vanilla Lua, and misleading if made valid, as a bracketed _expression_ normally produces exactly one value.