Aw: tail recursion optimization

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top