lua-users home
lua-l archive

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


How about this:

function f(a, b...)
    c, d...=g(a, b..., 1)
    e={c, {h()}...}
end

On the first line b is indicated to become a table to collect all varargs.
For compatibility, '...' alone would stand for 'arg...'. On the second
line, the first three dots indicate that d should collect additional
return values from g, and the second three dots stands for unpacking
b and using all the results as arguments. On the third line the same
'unpack' syntax is used to put all the return values of h into e after c.

Instead of being tuples or some pseudo-datatype, b and d should be
seen as tables, but the implementation could in both cases optimise these
as lazy 'stack tables' that are only turned into real tables when the
corresponding area of the stack needs to be popped.

-- 
Tuomo