[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 Length Operator and tables (bug?)
- From: Miles Bader <miles@...>
- Date: Tue, 17 Apr 2012 18:19:12 +0900
chris <csrl@gmx.com> writes:
>> I'd say the mere use of the operator means that the table creator
>> "knows" (in the Billings sense) that the table is either a sequence
>> or properly metamethoded.
>
> 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). As such, it is
> important to know if the length operator can be trusted or not. As
> it stands, it can not be trusted and so is useless without an
> external contract in place between the creator and consumer of the
> table.
Yeah, but such "contracts" are extremely common in code. Indeed, they
are a fundamental part of programming.
So there are many cases where the # operator can be trusted just fine,
thus ...
> Following my recommendation that the length operator always return nil
> unless __len metamethod exists
... this is a silly recommendation.
Granted there are many (you might term them "hand-wringing") languages
which err on the side of requiring ironclad evidence before allowing
anything, Lua is not such a language...
-Miles
--
Saa, shall we dance? (from a dance-class advertisement)
- 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