[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ipairs and extending numeric for loop
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 25 May 2010 11:11:24 +0200
On Tue, May 25, 2010 at 10:59 AM, Juri Munkki <jm_list@cameraid.com> wrote:
> Any comments on the "for i,v in 1, mytable do" and "for i,v in mytable do"
> ideas? Having had time to think about them since yesterday afternoon, it
> still feels like the syntax could be both a performance win and easily
> understood syntax as well. Plus, if ipairs is deprecated and removed,
> there would be a clean, safe and easy replacement for it.
I like 'for i,v in 1,mytable do' although the syntax is maybe a
little eccentric in using a number literal. I would certainly expect
it to work with other numbers, and if with literals, why not variables
as well?
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, ( not that I consider that a valid argument,
especially given its convenience for iterating over a collection and
simultaneously removing elements.) This argument would apply to your
proposed syntax as well.
steve d.