[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Get environment of a function
- From: "Alexander Gladysh" <agladysh@...>
- Date: Fri, 17 Mar 2006 21:35:38 +0300
> > 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.