[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proper tail recursion
- From: Thatcher Ulrich <tu@...>
- Date: Thu, 26 Jul 2001 16:15:01 -0400 (EDT)
On Thu, 26 Jul 2001, Roberto Ierusalimschy wrote:
> the complexity of the compiler (Lua uses a one-pass compiler, without any
> form of intermediate representation). ET once gave an interesting
> sugestion, where "normal" local variables live in the stack, and only local
> variables that are used by inner-functions would be allocated in the heap.
> The problem is how to generate code without knowing where a variable is
> going to live (when the compiler sees the inner function it can be too
> late...)
Interesting. Well, how about an *optional* optimizer, which takes in Lua
bytecode, looks for optimizations like that, and outputs the optimized
bytecode. I don't know much about Lua internals... does that sound
feasible? It seems like it could maybe be done as an external third-party
tool.
Re: tail calls... can the decision be made at the time of the recursive
call rather than at compile time? It's been a while since I've worked on
anything like that so forgive me if I'm being stupid :)
-Thatcher