lua-users home
lua-l archive

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

Ugg! Not a good choice, in my opinion! There is a "right choice" of iterator
for different types of object and it should be contextually selected not
having to remember whether to use pairs or ipairs. If you go down this way,
we'll end up defining __pairs or __ipairs to give error messages if the
wrong one is used! This is like saying the user has to use a different
function for adding real and complex numbers and if they pick the wrong one
they'll get a result, but a meaningless one.

Apart from this consideration of principle, it is using two metamethods to
do a half-assed job that could be properly done with just one!

I cannot see why this is syntactically impossible. Just check first for a
__iter when parsing the for statement, if not present, fall back to
processing as currently.

> -----Original Message-----
> From: [mailto:lua-
>] On Behalf Of Luiz Henrique de
> Figueiredo
> Sent: 10 June 2009 13:34
> To: Lua list
> Subject: Re: Next Version of Lua? (__iter metamethod)
> > Could I push my luck by asking if there is a position on '__iter'?
> There'll be metamethods __pairs and __ipairs. See