lua-users home
lua-l archive

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

On 21 June 2016 at 09:09, Viacheslav Usov <> wrote:
> 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.

I haven't done any benchmarks, but this module looks promising:

-- Hisham