lua-users home
lua-l archive

Re: lists with nil play nice for Lua 5.2

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


> 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

AltStyle によって変換されたページ (->オリジナル) /