lua-users home
lua-l archive

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




Note that I'm not the king of generic for iteration, and if this appears to change the semantics of generic for iterators, that is unintentional. The goal was to show the logic flow for selecting an iterator with metamethods. (It also assumes generic_for_iterate only proceeds after the code inside the
loop has been evaluated, of course.)

[1] http://lua-users.org/lists/lua-l/2010-05/msg00581.html



Correct me if I'm wrong - I'm having just a little trouble following
the code - but is this executed for every iteration? I posted an
example a few minutes ago that translates to the current definitions
of the generic and numeric for - so it's really a mapping from pure
syntax to one of the two for's - but I'm not sure where this one fits.

In terms of section 2.4.5 of the Lua 5.1.4 manual, this would be roughly analogous to the lines between "while true do" and "block". It's not perfect, though- as I said, I'm not great with generic for iterators, though I've been boning up in the last 15 minutes or so, and I think I could rewrite this to be a bit more clear.

I'm not sure I see where the loop body is getting executed either, but
again, I might just not be following it right.

It's not explicitly written- it would be somewhere between the call and the execution. (Like I said, the example is far from perfect.)

~Jonathan