lua-users home
lua-l archive

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


On Tue, May 25, 2010 at 5:11 AM, steve donovan <steve.j.donovan@gmail.com>
> ...
> As for 'i,v in mytable', it involves resurrecting an old syntax -
> there's an interesting proposal that 'for x in t do' should invoke an
> __iter metamethod on t if it is not a function.  That would be very
> finger-friendly!
>
> But the main argument against ipairs seems to be that the numeric-for
> makes it redundant,

A very frequent case is iterating over a list without using the integer index.
Would it make sense in this case to use the following form:

  for x in t do ...

  -- equivalent to current:   for _, x in ipairs(t) do ...

We could then use the numeric for for those cases where ipairs() and
the index are used today.

What do you think?

Phil