lua-users home
lua-l archive

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


> >   eat_first = function(_, ...)
> >     return ...
> >   end

>     Can't you do:
>
> eat_first = function(_, ...)
>     return unpack(arg)
> end
>
> ?

AFAIK, in 5.0.2 each call to vararg function implicitly creates arg
table to hold passed parameters (in 5.1 '...' represents a list of
parameters, not the table, so extra no table creation is needed).

So this is basically the same reason I do not want to do

 local res = { func() }
 setfenv(func, e)
 return unpack(res)

(while solution with eat_first() looks more elegant, it have the same
overhead as this one).

Thanks,
Alexander.