lua-users home
lua-l archive

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


On Oct 6, 2013, at 12:03 AM, David Heiko Kolf <david@dkolf.de> wrote:

> Dirk Laurie wrote:
>> Cheap alternative: Fixed-length table. Length defined once for all. Larger
>> indices treated as non-numeric. This may actually cover quite a large
>> number of actual use cases
> 
> This was the pre-5.1 way, where the length could be either stored in an
> 'n' field or in an internal table property.
> 
> Out of curiosity, does anyone have links to discussions why the
> possibility of storing the length in a field of the table (as `t.n`)
> isn't used anymore?  Why doesn't the default length operator check for
> `t.n` first before doing the binary search?
> 

Well one big advantage is that # has a corresponding meta function, so it's easier to create abstractions than using the old "n" system.

@Dirk: "Larger indices treated as non-numeric?" What do you mean?

And in either case, you would still have O(n) performance hot, which Roberto apparently feels is unacceptable.

--Tim