lua-users home
lua-l archive

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


Am 30.08.2014 um 06:38 schröbte Tim Hill:

On 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?


-Andrew

You can of course use table.pack() to capture vararg return values, which allows you to do what you want indirectly, ]...]

I prefer a tail-call to another vararg function in such cases ...

    return handle_pcall( pcall( fun, ... ) )


—Tim


Philipp