lua-users home
lua-l archive

Re: Definition of a sequence

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


2015年06月11日 12:03 GMT+02:00 Mike <lua-l@inbox.ru>:
> On 2015年6月11日 11:12:07 +0200
> Oliver Kroth <...> wrote:
>> > Unless a __len metamethod is given, the length of a table t is only defined if the table is a sequence,
> I see, it is reasoned. If we strictly follow the logic,
> the length operator should ideally return nil in these cases,
> because "it usually represents the absence of a useful value".
Detecting that a particular table is not a sequence, as has been
debated ad nauseam on this list, is an O(n) operation which you
can code for yourself if you really must have it.
> I see, it is reasoned. If we strictly follow the logic,
> the length operator should ideally return nil in theese cases,
> because "it usually represents the absence of a useful value".
The value is useful, because it has the property that
 t[#t+1] = x
will store x into an empty slot. I wish that the documentation would
restore at least that half of the boundary property.

AltStyle によって変換されたページ (->オリジナル) /