lua-users home
lua-l archive

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


2014-08-30 6:03 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:
> 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.

No, you seem to be the first person who has thought this notion
worth sharing.

I can't see how it can be implemented. `...` is a strand of stack
space belonging to the calling routine and of fixed size. All that
makes it variable is that its size is not known at compile time.

Heck, I don't even see what it can mean. Lua does not have
call-by-name, it only has, for two of its types, mutable values.
What will that assignment to `...` do if the call is
   o:method(fun,1,2,3)?