[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT2 vs. vararg
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 25 Nov 2009 21:14:16 +0300
On Wed, Nov 25, 2009 at 15:20, Mike Pall <email@example.com> wrote:
> 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.
Well, I planned to create visual flow-programming DSL with gotos (as
links between commands), which would be translated to Lua code heavily
abusing tail recursion...
That is, probably, the only case where I can't see easy non-recursive
>> 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])(...)
> Yes, I'm pretty sure this can be optimized away. The only thing
> preventing it right now is the varag function and select().
So, you're saying that this optimization will most likely make it into
Can I start writing code in this way? :-)
Sorry for pushing you. If you can't say it now, I'll understand.