lua-users home
lua-l archive

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



On 15-Sep-04, at 7:28 PM, Fabio Mascarenhas wrote:

Then the right thing is the behavior of Lua 5.0.2 (in fact, this is the way for is explained in the reference manual :-) ).

That is true, "right" is quite subjective. I had quotes around it at first, but they seemed redundant.

You can easily have it the other way by explicitely declaring another local:

Yes. But it is hard to think of a case where you would not want the new behaviour.

Well, I'm sure this new way will be documented in the 5.1 reference manual. :-)

I have no doubt. This does not mean that it is necessary to define the behaviour in the case of assigning to an index variable, though -- I have no problem with explicitly documented undefined behaviour; assigning to index variables is probably poor style in any event.

And the loop variable is not really created anew each iteration; the same register is reused. There is no performance penalty.

In fact, it is quite possibly slightly faster for "for ... in" statements. The loop variable is *conceptually* created anew each iteration.