[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Next Version of Lua? (__iter metamethod)
- From: "John Hind" <john.hind@...>
- Date: Wed, 10 Jun 2009 14:16:22 +0100
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: firstname.lastname@example.org [mailto:lua-
> email@example.com] On Behalf Of Luiz Henrique de
> 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
- Next Version of Lua?, Olivier Hamel
- Re: Next Version of Lua?, Jim Whitehead II
- Re: Next Version of Lua?, Olivier Hamel
- Re: Next Version of Lua?, Luiz Henrique de Figueiredo
- Re: Next Version of Lua? (again, \x## notation), Ico
- Re: Next Version of Lua? (again, \x## notation), Luiz Henrique de Figueiredo
- RE: Next Version of Lua? (__iter metamethod), John Hind
- Re: Next Version of Lua? (__iter metamethod), Luiz Henrique de Figueiredo