[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: inadequate documentation for select and table.unpack
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 20 Jun 2016 16:04:31 -0300
> A point that does rate some extra explanation, but perhaps iin PiL
> rather than the reference manual, is that 'select' is in fact an
> extremely efficient operation, involving no actual copying of
> arguments. There is no API equivalent, because none is needed.
> It returns the stack exactly as it found it, but reporting a possibly
> different number of return values.
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.