And to answer the questions every Schemer will have, no the runtime doesn't yet support tail calls or continuations.
And to answer the questions every Schemer will have, no the runtime doesn't yet support tail calls or continuations.
A Wasm target of the Chez/Racket compiler might be an easier way to get fast and proper evaluation in Web browsers.
Having this as guarantee allows all the control flow concepts to be reduced to recursion and function calls.
A kind of purity when we reduce a programing language to the basic set of primitives that provide the building blocks to create any kind of programming paradigm, this is in a way the beauty of Scheme, moreso than Lisp.
However as great as tail calls are they can't practically implement all control flow concepts. Eg they aren't really all that great for modelling exceptions, I think.
TCO is technically in the ECMAScript specification (since 2015) but hasn’t been implemented across browsers or runtimes (with a few exceptions).
Dr. Axel has written a good explainer of TCO in the context of Javascript here https://2ality.com/2015/06/tail-call-optimization.html
Do you use this strategy for implementing recursion? Are there consequences or trade offs?
For others who are curious, see
1) https://stackoverflow.com/questions/25228871/how-to-understa..., and 2) https://raganwald.com/2013/03/28/trampolines-in-javascript.h...
It's not the only strategy though.