News for hackers. Stuff that matters.
Re:Asynchrony Is Not Concurrency by psychoslave on Saturday July 19, 2025 @07:09AM (#44614462)
For the first one, it really feels like only a matter of how you break lines. Sure there is also the matter of anonymous function syntax, but

The latter is more fair, here is a possible solution:

  const gen = (function* () {
    for (let i = 0; i < n; i++) yield a(i);
  })();

  const run = next => !next.done && next.value.then(() => run(gen.next()));
  run(gen.next());
Or something similar using reduce. But in both cases, it illustrates the point, I guess.

But if we are at point we can introduce new keywords/syntax in the language, it would just as well possible to come with something like

  a.chain(b, c)
In case you need to pass parameters

  a.chain([b, p1, p2], c)
And for the latter case

  const indexes = (function* () {
    for (let i = 0; i < n; i++) yield i;
  })
  a.through(indexes)
Re:Asynchrony Is Not Concurrency by Yoric on Saturday July 19, 2025 @07:33AM (#44614609)
Well, sure, if you have `yield`, you pretty much have `await` already, as `await` is thin syntactic sugar on top of `yield` in all languages other than OCaml.