[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table design choices
- From: David Kastrup <dak@...>
- Date: Tue, 24 Nov 2009 10:21:13 +0100
spir <denis.spir@free.fr> writes:
> (below just wish to know about original design choices I couldn't find in docs about lua history -- I don't mean there bad, nore good)
>
> -1- reasoning on single container type
> Why is a single container type supposed to be better?
Simplicity.
> My view is actually there are three use cases, which map to distinct conceptual notions:
> * sequence = indexed values
> * "directory" = named (or more generally key-ed) value
> * structure = either "record" (eg position={x=1, y=2}) or "object" (eg point={pos={1,2}, color="#ffffff"})
> The first 2 cases are close, but the latter is really
> different. Rather a kind of named tuple.
Since strings are interned in Lua, not enough difference to warrant the
additional complications.
> -2- reasoning on choice of table
> Why is a table supposed to be better as single container type?
> (compared to lisp/scheme list)
Random access is a frequent enough requirement for algorithms to make
O(n) access undesirable.
--
David Kastrup