lua-users home
lua-l archive

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


On Wed, Nov 25, 2009 at 15:20, Mike Pall <mikelu-0911@mike.de> 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
alternative.

>> 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().

So, you're saying that this optimization will most likely make it into
LJ2 release?
Can I start writing code in this way? :-)

Sorry for pushing you. If you can't say it now, I'll understand.

Thanks,
Alexander.