lua-users home
lua-l archive

[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:

Done in Lua so it needs to create an extra table...