G
glathoud
Yes, at least within the ECMAScript 5 strict mode, an interpreter *could* implement Tail Call Optimization (TCO) [1]. But the ECMAScript 5 standard does not force any interpreter to implement TCO.
Right now, one solution to have TCO in a safe and performant manner is to mark the tail-recursive parts of the code you want to optimized, and have another program automatically optimize your code [2]. Also server-side code "compilation".
IMHO this remains a bit constraining and hopefully interpreters will implement TCO someday.
Best regards,
Guillaume
[1] http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls
[2] http://www.glat.info/jscheck/tomrec_prod.html
Right now, one solution to have TCO in a safe and performant manner is to mark the tail-recursive parts of the code you want to optimized, and have another program automatically optimize your code [2]. Also server-side code "compilation".
IMHO this remains a bit constraining and hopefully interpreters will implement TCO someday.
Best regards,
Guillaume
[1] http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls
[2] http://www.glat.info/jscheck/tomrec_prod.html