lua-users home
lua-l archive

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


on 8/19/04 8:11 PM, Rici Lake at lua@ricilake.net wrote:

> tuples differ in two ways from tables: one is that they are immutable
> (in my proposal) which, in an imaginable implementation, would make them
> internable and therefore quite different from tables. (Or, even if not
> interned, compared by value and not by object identity.) The other
> difference is that there size is fixed and known.

With respect to memory allocation, I think much of the benefit of tuples
could probably be gained by avoiding some trips to malloc and free by
caching particularly common object sizes. So, that argument hasn't been a
compelling reason for supporting tuples.

The notion of interned tuples, however, is quite appealing since it could
simplify and reduce the memory consumption for various things like function
result caching.

Finally, if tuples were introduced as a base concept, then I think unpack
should probably work on both tuples and tables. Similarly, ipairs should
work on tuples. At the same time, I wouldn't expect these to work on
arbitrary function closures.

Mark