lua-users home
lua-l archive

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


>> Could x[] be syntactic sugar for x[#x+1] ?
>> It would make appending to lists so much nicer.

> I would worry about the hidden performance implications of this. The
> magic # operator performs a binary search of both storage parts of the
> table, which is an O(log N) operation.

The # operator has constant complexity I suppose. It doesn't deal with the associative part of a
table at all. Moreover, it is not a true "length" operator for the dense part as it works that way
only for well-managed sequences.