lua-users home
lua-l archive

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


http://lua-users.org/lists/lua-l/2010-05/msg00338.html

I'm late to reading this thread, but just today I decided to go try to wrap my head around how the continuation logic worked.

I had essentially the same reaction. As currently structured, I have to write my continuation logic twice. I appreciate the lack of tail recursion guarantees in C, but it still seems muddled and it might be worthwhile at least to figure out whether there is a standard way to write yield-friendly functions in a simpler way. (That said, I do most of my programming in Lua as opposed to C, so maybe I just care that pcall no longer interferes with yielding.)

I will note, however, that the implementation of foreachi arguably has a bug in that it recomputes n each time the continuation is invoked which means that if the function changes the length of the table this won't be seen unless the function also yields.

Mark