[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: Sun, 17 Aug 2014 17:57:45 +0200
2014-08-17 15:00 GMT+02:00 Jan Behrens <jbe-lua-l@public-software-group.org>:
> Therefore, I'd argue that in Lua 5.3.0-alpha, ipairs is merely
> syntactic sugar... unless it's an explicit feature that the ipairs
> iterator will evaluate the length multiple times. Is it?
[... followed by many other things that ipairs might be instead,
the deatials of which I do not wish to address, and ending in ...]
* Keep the __ipairs metamethod to allow customized behavior
When I first learnt Lua, there were three things that I knew
I did not understand properly and so I did not use them.
1. Coroutines
2. The C API
3. The generic 'for'
I thought of 'pairs' as something provided for the convenience
of idiots like me who do not understand the generic 'for' and
magically provide what is needed. `ipairs`, to me, was similar,
but not really necessary because one could also use the
arithmetic for (I started just as 5.2 reached alpha, so #tbl
was available).
Later, when I started mastering the generic 'for', `pairs` and
`ipairs` became examples of parametrized iterators. I now
think that I understand the generic `for`, so I no longer use
`pairs` and and only the absence of the more basic
ties me to `ipairs`.
The more I read proposals like the part I don't quote, or like
what has been implemented in 5.3.0 alpha, the more
I admire the simplicity of the 5.2 sample iterators, and the
more those proposals begin to sound like things that could
be replaced by "read PiL Chapter 7 and write your own".
- 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
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Doug Currie
- Re: ipairs in Lua 5.3.0-alpha, Coda Highland
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens
- Re: ipairs in Lua 5.3.0-alpha, Andrew Starks
- Re: ipairs in Lua 5.3.0-alpha, Jan Behrens