[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: I miss table.foreach
- From: Andrew Starks <andrew.starks@...>
- Date: Wed, 4 Sep 2013 22:06:30 -0500
On Wednesday, September 4, 2013, Tim Hill wrote:
On Sep 4, 2013, at 5:31 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> One would not like to be caught redesigning Lua on this list! :)
>
> if i did, then I'd say that it would be nice if "for" received a table after "in", it would look for the "__in" metamethod and call it with the table as the argument.
>
> It isn't a big deal though, wich is why I won't wish for it publicly
>
> :)
>
> -Andrew
Another example of the somewhat incomplete use of metamethods in Lua at present. However, remember that for "for … in ..." statement really expects three arguments, not one (we are just used to all three being the return values of a generator function such as pairs()). Not saying it can't be done, though.
--Tim
True. Also, my non-existent idea was kinda dumb in that "__next" is really the last missing iterator metamethod, not "__in".