[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Array subtype is conceptually simplest
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 24 Oct 2018 10:53:22 +0200
Op Di., 23 Okt. 2018 om 17:56 het Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> geskryf:
>
> Wouldn't an array *library* be a simpler solution?
>
Since you quote no previous post, I assume that you are replying to my
original post, which started:
> Every Lua 5.2 program you ever wrote in which somewhere the argument
> to 'ipairs' is a table with an __index metamethod, has a chance of
> being broken in Lua 5.3, because that metamethod _will_ be invoked in
> a way that probably is not the reason why you supplied it.
So no, an array library would not be a solution at all, unless
accompanied by an "apairs" function in the standard library.
Up to Lua 5.2, 'ipairs' gave you a subset of what 'pairs' gave you.
The simultaneous decision to make it possible for 'ipairs' to deliver
a pair that 'pairs' can't see, and to abolish the __ipairs metamethod
that could have avoided that possibility, was a breaking change.
Linters should warn you against "ipairs" (maybe some of them already
do?)