logoalt Hacker News

Mond_ • today at 2:19 AM • 1 reply • view on HN

Are you sure you're up to date?

The async design changed multiple times, and the current approach is that of requiring passing an I/O interface that encapsulates the logic, same approach as for passing around an allocator.

This effectively makes all I/O bound code "quasi-async", and it's all explicit and the caller is in control.


Replies

simonask • today at 9:35 AM

As far as I understand it, the idea is that the IO interface is "magic" in the sense that it affects which version of a function gets called: either the synchronous, linear version, or the asynchronous, stackless, suspensible state machine version.

This has a lot of implications, especially for function pointers and other forms of dynamic dispatch.

My personal take is that async code is fundamentally different from sync code, because the weights of various tradeoffs change dramatically. In my view, "colorless" functions are not really a worthwhile goal in the first place. But I've been wrong before, so it may turn out to be great, we'll see.

➕ show 1 reply