5 ms·
Sorry if this is a stupid question but when you use continuations-passing style, what happens to the stack in javascript? Does it clean it self up or does the l
by nkassis 15y ago
Sorry if this is a stupid question but when you use continuations-passing style, what happens to the stack in javascript? Does it clean it self up or does the language just keeps going functions all the way down and fills up?
- sausagefeet 15y agoIf you're doing CPS in a language with tail-call optimization then the same stack frame will be used for all your function calls. I don't know if V8 does this. In something like Node you don't do full CPS, you have portions of your code in CPS but usually only a few layers deep as you need to give control back to the event loop at some point.
- ricardobeat 15y agoI don't think JS has tail-call optimization. At some point you'll likely hit an error similar to too much recursion, but it would require a scope chain in the thousands.