lua-users home
lua-l archive

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


On Fri, Aug 29, 2014 at 9:03 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> I'm curious about why it is not possible to do something like:
>
> `function o.method(self, fun, ...)
>
> success, ... = pcall(fun, ...)
> --vararg now return values of fun
> -etc.
>
> end
> `
>
> I assume this has been a topic, because its use would be pretty obvious. I
> couldn't come up with anything via the googles, so could someone point the
> way to where this was discussed?

It would be cool to reassign the stored varargs, but I imagine it
wouldn't look too pretty on the stack end of things?  It would be
costly to move the new varargs into place over the old ones of course
-- I'm not sure how varargs are stored on the stack, but I'm thinking
that while it's possible to move the stack frame forward to "forget"
the previous varargs I don't know how you'd point to the new ones
(assuming the lua stack frame has an organized format).

We need more experts!  *rings cowbell*