lua-users home
lua-l archive

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


This question is specifically about function calls and how many return
values are to be accepted by the caller. Is below a correct
description:

Lua functions return multiple values. The caller has to decide how
many arguments to accept.

1. If the function call is the last expression in a function argument
list, or in a return statement, or in a table constructor then we have
to allow unlimited values - which is represented by -1.

2. If the function call is in an assignment expression and is the last
expression, then the number of return values to accept is equal to
corresponding var plus any excess vars.

3. In all other cases the function return values are truncated to 1 result.

So when parsing we can by default set number of results to 1, but
extend it for cases 1 and 2.

Thanks and Regards
Dibyendu