lua-users home
lua-l archive

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


Hi everyone on the list!

This is about the vararg-usage in lua 5.1, excluding the compatibility options.

It occurred to me that determining if a function is a vararg-function or not can be determined purely based on whether "..." is used in the function body or not.
(Or, equivalent, if the VARARG opcode is used anywhere).

Now, in lua 5.0 it was necessary to have ... in the function definition, since that determined if "arg" inside the body referred to a global variable or a table of extra arguments.
In 5.1 without compat-options, there is no such ambiguity. "..." can only refer to the enclosing functions variable arguments.

Thus, I propose for the next major release, that including "..." as the last parameter in a function definition should be made optional, allowing you to write lua code such as:
function() return ... end

Of course, this assumes that both 1) the old style variable argument is removed and 2) no other conflicting changes are made to the current vararg implementation.

Sincerely
Kristofer