lua-users home
lua-l archive

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


Most of the critical points have been mentioned, but I just wanted chime in on the tuples issue.

The thing I keep running into myself is that Lua has no built-in way to hash by multiple values.  You have to 
build an identifying string to hash by, or fake it with nested tables.  Tuples can solve this problem.

I want immutable interned tuple values for exactly this reason.  They give you higher-order table indices.

Tables do not solve this problem because they are objects: they have both identity and value.  Even with some kind
of __hash metatable entry that describes how to index them as value-keys (instead of by identity), changing their
value would interfere with the indexing.  "Weak tuples" have exactly this problem, and are frankly unnecessary.  
Weak referencing can be done with just tables, by putting your table-referencing tuples in weak tables, and the
system is more correct and orthogonal as a result.  Functional tuples have the identity problem too, since they
are objects and not interned values, and they don't have weak references either.  Weak tables are enough.

If you really care about mutable tuples for performance reasons, we should just call these 'records' or something 
instead of confusing the tuple issue.  CTMCP (the Oz book) has some great perspective on this stuff.

I do like the proposed '...' semantics, though it might be error prone since '..' is awfully close.  Why not let
the '...' identifier/operator be indexed directly with table semantics, like ...[i], instead of some goofy syntax?  
I think this is great for varargs, but please don't spoil tuples to make it work.

Tuples should be real values, nested and all, and not just a shill for '...' syntax and semantics.  This is #1 on 
my wishlist of Lua features.  There are cases where it would be so much better than string building or table 
nesting for multi-value indices that Lua would really benefit as a whole.

Just my 2c, but I'm passionate and concerned here because I love Lua.

-Lucas