Subj : Looking for Spidermonkey equivalent of Mozilla/DOM trick... To : netscape.public.mozilla.jseng From : Anton van Straaten Date : Wed Nov 26 2003 03:11 pm I have a Javascript program implemented partly in continuation-passing style (it was converted from Scheme). Because of the CPS, the program can recurse very deeply - deep enough to fill the Javascript stack before getting much useful work done. Happily, it turns out that in this particular program at least, it's possible to reduce the stack depth requirement, by every now and then "resetting" the process by passing a closure to the DOM window.setTimeout method and allowing the current procedure to terminate. With this trick, the program works very well, particularly under Mozilla - it can reach levels that would have required recursing a million levels deep. (IE is not nearly that good.) Since this program is already structured around setTimeout, I'm wondering if there are any easy tricks similar to setTimeout that I can use under Spidermonkey without DOM? I could implement a trampoline-style top-level loop and do this myself, I'm just looking for a lazy way out. (BTW, I'm aware of the CPS version of Rhino with tail-call optimization. I'm guessing nothing like that currently exists for Spidermonkey...) Anton .