lua-users home
lua-l archive

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


Apart from convenience, the new ipairs also uses an __ipairs
metamethod where available, making the "for i, v in ipairs(c)" idiom
useful for iterating on user-defined sequences, not just regular Lua
lists. It would feel strange to use pairs to iterate on sequences.

--
Fabio Mascarenhas


On Thu, May 20, 2010 at 12:24 AM, Shmuel Zeigerman <shmuz@013net.net> wrote:
> Mark Feldman wrote:
>>>
>>> There are a few other "syntactic sugar" constructs in Lua, so
>>> why is ipairs singled out?
>>>
>> It's trivial to add yourself, as demonstated in PIL:
>> [...]
>
> It's a matter of convenience. Those wanting ipairs to stay, want it
> out-of-the-box. (I, for one, wouldn't like to "require 'ipairs'" in every
> little script I write).
>
> --
> Shmuel
>