[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 Length Operator and tables (bug?)
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 17 Apr 2012 11:16:41 +0200
On Tue, Apr 17, 2012 at 11:08 AM, chris <csrl@gmx.com> wrote:
> Therein is your fallacy. The creator self knowledge was never in question, it is
> the consumer of the table that may not know much about the table (assuming lack
> of contract).
But it would be a poor API that did not give some kind of guarantee.
In fact, most people do just fine with a dodgy #, once they have
realized that Arrays May Not Have Holes. The contract is that if the
API gives you an array, you can assume that they've done their due
diligence and left no holes, _or_ defined __len to enforce the
intended meaning. (If not, it's a bad API)
> Following my recommendation that the length operator always return nil unless
> __len metamethod exists, the creator of the table who "knows" what the table is
> has the ability to define such a metamethod,
That would seriously break most existing Lua code, and as such, is
never going to happen.
steve d.
- References:
- Lua 5.2 Length Operator and tables (bug?), csrl
- Re: Lua 5.2 Length Operator and tables (bug?), Dirk Laurie
- Re: Lua 5.2 Length Operator and tables (bug?), Jose Torre-Bueno
- Re: Lua 5.2 Length Operator and tables (bug?), Krunal Rao
- Re: Lua 5.2 Length Operator and tables (bug?), Luiz Henrique de Figueiredo
- Re: Lua 5.2 Length Operator and tables (bug?), chris
- Re: Lua 5.2 Length Operator and tables (bug?), Miles Bader
- Re: Lua 5.2 Length Operator and tables (bug?), chris
- Re: Lua 5.2 Length Operator and tables (bug?), Miles Bader
- Re: Lua 5.2 Length Operator and tables (bug?), chris
- Re: Lua 5.2 Length Operator and tables (bug?), Dirk Laurie
- Re: Lua 5.2 Length Operator and tables (bug?), chris