[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Cons, tuple and __slots__ -- a simple mechanism to implement them in Lua
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 16 Sep 2011 10:00:11 +0200
On Fri, Sep 16, 2011 at 7:48 AM, Dirk Laurie <dpl@sun.ac.za> wrote:
> So: sometimes good, sometimes bad.
Actually, such a patch would be still useful for embedders that need
to squeeze some space efficiency out of their customized Lua, without
actually getting into mainline Lua. Lua has a very accepting
patch-culture.
What's interesting is that it provides a possible answer to the
question "what is ...?'. If ... is implemented as a Xavier-tuple, then
it must behave like a variable-list:
local a,b,c = ...
local args = {...}
local a = select(1,...)
What completes the picture and makes ... a first class value is if
there is a function or construct that allows it to be treated as a
value:
local args = @... (or just tuple(...); we don't need a new sigil, but
a function call would be more expensive)
Then 'args' now has type 'tuple'. Having a distinct new type means
that it gets a shared metatable and one can establish suitable
equality semantics etc.
steve d.