lua-users home
lua-l archive

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


> This is why "PUC approval" and incorporation into Lua 5.3 would really
> help here.

I really do not think that ipairs + __ipairs is a good generic iterator
interface. That was never the intention when we created __ipairs. Among
other problems, it forces an object to have only one "true" iterator; it
is too "object" centric. (For instance, how do you fit the result from
"string.gmatch" into that shoe? Or io.lines, with all its variations?)
Yes, I saw it, we end up with a ultra-super-cool-
-special-extended-ipairs :-)

I think Lua already has a good generic iterator, in the form of a
function returning values, as used by 'load'. It is simple, easy to
use, easy to explain, good performance. Yes, I know, we have to create
a new closure for each iteration, what a waste!  Come on... If we want
to do high-level programming without creating things (closures, tables,
objects, etc.), we need a quite different language (maybe C++?).

-- Roberto