lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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)