lua-users home
lua-l archive

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

Alexander Gladysh wrote:
> I see. Would recursion without varargs be slow as well? (I'm asking this in
> general, not related to the arguments().)

In theory, recursion (without varargs) could be optimized as well
as any loop. In practice, it probably won't. Simply because few
real-world Lua code makes use of recursion for time-critical parts.

> The question is: can LJ2 be made to optimize the function below away?
> (That's what args_unroll_simple is.)
>   local arguments = function(...)
>       local n = select("#", ...)
>       -- Assuming cache is pre-populated for all possible use-cases
>       return assert(arguments_cache[n])(...)
>   end

Yes, I'm pretty sure this can be optimized away. The only thing
preventing it right now is the varag function and select().