[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: Sat, 16 Aug 2014 22:42:01 +0200
2014-08-16 20:08 GMT+02:00 Tim Hill <drtimhill@gmail.com>:
>
> On Aug 16, 2014, at 11:02 AM, Tim Hill <drtimhill@gmail.com> wrote:
>
>>
>> On Aug 16, 2014, at 12:05 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>
>>>
>>> for k,v in ipairs(tbl) while ok(v) do
>>> end
>>>
>>> and
>>>
>>> for k,v in pairs(tbl) if ok(v) do
>>> end
>>>
>>
>> Presumably syntactic sugar for (in the while case):
>>
>> for k,v in ipairs(tbl) do
>> if not ok(v) then break end
>> ...
>> end
>>
>> Doesn’t seem to buy much, and I don’t like the “if” version, it seems clumsy to read.
>>
>> —Tim
>>
>
> Unless you mean:
>
> for k,v in ipairs(tbl) do
> if ok(v) then
> …
> end
> end
>
> Which is more interesting to me, and I would agree that “if” is a better keyword in this case.
That's the `for ... if ...do` form. The other one is the
`for ... while ... do` form. No reason why you can't havel
both of them in the sane statement.
I'll confess to be influenced by a language called Turing [1] which has
only one, but extremely versatile, "loop" statement.
[1] <www.ompsci.ca> The language used to be proprietary (the
developers licensed it to the Ontario Ministry of Education as
a teaching language) but is now open-source.
- 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, Dirk Laurie
- Re: ipairs in Lua 5.3.0-alpha, Tim Hill
- Re: ipairs in Lua 5.3.0-alpha, Tim Hill