lua-users home
lua-l archive

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

On Mon, Jun 20, 2016 at 9:04 PM, Roberto Ierusalimschy <> wrote:

> That is not true. 'select' can be quite slow for a large number of parameters (where "large" starts in the order of a few dozen). In particular, a typical loop in a vararg function using 'select' is quadratic with the number of arguments, while creating a table and traversing it is linear.

That could be why the manual and PiL are a little shy about this function.

Yet, this discussion has revealed that even those familiar with select have very wrong ideas about it. It looks like there is no really lightweight mechanism in the language to access an arbitrary variable in a variadic function. It may be that Lua could benefit from some new syntax for that.

Another possibility could be in making {...} very lightweight. That syntax could create a new internal type that is essentially just a maker; and in all the cases when such a value can potentially be leaked from the current function, it gets replaced with a real table. I should say that I am not sufficiently familiar with Lua's internals, so this could be a ridiculous thing to propose :)