I guess we'll see when the spec is released whether they mean static or dynamic tail calls. I'm guessing the latter would require a rather tricky analysis to work in JavaScript, and may not be what they will include in the spec.
Does scheme mandate that the compiler must be able to discover tail calls that occur at any point, say, after functions are redefined? For example, if you define some function f to call a function g that is not yet defined, and then later you dynamically define g, and the functions end up being mutually tail-recursive, does scheme mandate this must be optimized through tail recursion?
- Maxime
On 2011-01-30, at 1:18 PM, chevalma@iro.umontreal.ca wrote:
It should be possible to analyze the tail recursive functions and transform them so the recursion becomes a loop in the CFG. This way we can keep the IR the same-old SSA.
That is not sufficient. Correct support for tail-calls must be dynamic. For example if you have a tail-call to g in f, and in g you have a tail-call to f (mutual recursion with tail-calls). It has to be dynamic because g might be the defined with an eval, or other dynamic method.
The bottom line is that there must be a tail-call instruction (often called "jump") to transfer control to functions without stack growth.
Marc
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list