[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Next Version of Lua? (__iter metamethod)
- From: "John Hind" <john.hind@...>
- Date: Wed, 10 Jun 2009 17:21:06 +0100
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] On Behalf Of Adrian Sietsma
> Sent: 10 June 2009 16:20
> To: Lua list
> Subject: Re: Next Version of Lua? (__iter metamethod)
>
> I often have multi-use tables, such that t[id] = t[n] = object.
> I can then lookup objects by id, or iterate them with ipairs.
> In this case, how would your code 'contextually select' the iterator ?
>
So why would you want to use "pairs" in this case? If your table meets the
requirements for "ipairs" and you do not care what order the elements are
returned in, what is wrong with "ipairs"? Either "ipairs" works and is
sufficient, or it does not, in which case you have to use "pairs". In any
case, metamethods only impact if you choose to use them, so nothing breaks
your code. Why would you want to use the proposed "__pairs" or "__ipairs"
metamethods?
> > 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!
> Is the solution half-assed, or your understanding of the problem ?
>
Always possible, as of course may be your understanding! Actually I do not
think there is a problem here - just an opportunity for improvement, or for
taking a backward step.
- References:
- 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
- RE: Next Version of Lua? (__iter metamethod), John Hind
- Re: Next Version of Lua? (__iter metamethod), Adrian Sietsma