News for hackers. Stuff that matters.
Re:Scheme in Scheme on WASM in the Browser by skrebbel on Friday December 15, 2023 @01:23PM (#38656949)
I don’t know their motivations, but having the same code work fine on one JS engine / browser / browser version, but totally stack overflow on another seems like suboptimal to me. Explicit tail calls let you error out properly at the call site, Babel-style downcompile it to a loop of some sort, all that stuff.
Re:Scheme in Scheme on WASM in the Browser by odyssey7 on Friday December 15, 2023 @02:00PM (#38657352)
This could be surprising, but the scenario already exists in production. In JavaScript's strict mode, Safari applies tail call optimization, but systems relying on V8 don't.

To illustrate, the following code causes a stack overflow for me in both Google Chrome and in Node.js, but runs without issue in Safari.

  "use strict";
  const countdown = (n) => n == 0 ? console.log('done') : countdown(n-1);
  countdown(100000);