[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Writing Iterator in C
- From: "Peter Cawley" <lua@...>
- Date: Wed, 31 Dec 2008 15:56:00 +0000
On Wed, Dec 31, 2008 at 3:51 PM, Ralph Hempel <firstname.lastname@example.org> wrote:
Except it doesn't work: http://codepad.org/MfGGdS56
That's what I thought reading the PiL manual, but I was not sure
Peter Cawley wrote:
Note that p (the control variable) is changed in the body
of the for loop, and this works fine in pure Lua.
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).
so I tried it. I was a bit surprised that it worked too.