[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lists with nil play nice for Lua 5.2
- From: "Wim Couwenberg" <wim.couwenberg@...>
- Date: Wed, 1 Aug 2007 14:41:10 +0200
> Another option is to implement tuples. We can implement them as C
> functions with upvalues (PiL2, p. 257). With a few extra lines of code,
> we get the following:
>
> a = new.tuple(2, nil, "foo")
> #a -- not available; perhaps a"#" ???
> a:insert("baz") -- not available (tuples are immutable)
> a(3) -- yields "foo"
> a() -- yields 2, nil, "foo"
> for i, v in a do ... -- or something like this...
Which reminded me of:
http://lua-users.org/lists/lua-l/2006-03/msg00250.html
Done in Lua so it needs to create an extra table...
--
Wim