[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ipairs in Lua 5.3.0-alpha
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 15 Aug 2014 19:41:06 +0200
2014-08-15 18:37 GMT+02:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
> If the goal is only to reduce calls to length, another option would be
> to modify ipairs so that it stops in the first nil entry with an index
> larger than #t. That would have some nice properties:
> ...
> - It is more compatible with the original semantics of ipairs for
> regular tables. (If no metamethods, it stops in the first nil, which
> should be larger than #t in a proper sequence anyway.)
Even more compatible would be to revert to the version in 5.3.0-work3.
"iterate over the pairs 1,t[1]), (2,t[2]), ..., up to the first integer key
absent from the table." I cannot understand why this simple and
understandable specification was changed in 5.3.0-alpha.
However, I don't think __index should be respected by ipairs.
It should just be the positive integer version of pairs, not something
sophisticated and arcane.
If one wants #t (including __len) to be brought into the picture,
the arithmetic `for` is available.
- References:
- Speed of # operator (Was: ipairs in Lua 5.3.0-alpha), Dirk Laurie
- Re: Speed of # operator (Was: ipairs in Lua 5.3.0-alpha), Enrico Colombini
- Re: Speed of # operator (Was: ipairs in Lua 5.3.0-alpha), Jan Behrens
- Re: Speed of # operator (Was: ipairs in Lua 5.3.0-alpha), Roberto Ierusalimschy
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Roberto Ierusalimschy
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Roberto Ierusalimschy