Comment by faldor20

13 hours ago

It seems like a bit of a shame that wasm got support for exceptions but doesn't support effects which are a generalisation of the same concept. https://wasmfx.dev/

I'm guessing this may be because exceptions exclusively require stack unwinding where as effects require full stack switching.

Seems like there is still progress on that though which gives hope https://github.com/WebAssembly/stack-switching/blob/main/pro...

Thanks for that link! There goes my Saturday morning.

After a bunch of middle clicking I landed here [0]. So if I understand correctly, the current stack switching proposal depended on exception handling to be implemented first for resume.throw, so that bit was blocked until now.

But it's also further along than you might assume [1], i.e. you can already invoke Wasmtime with `-W stack-switching` and hit the boundaries where the experimental implementation breaks.

Sadly though, like many ambitious Wasm things that don't have revenue directly attached to them, it now seems partly a case of finding someone willing to sponsor or finish the remaining work [2].

I also found the list of open stack-switching issues[3] useful.

(also, minor nit - Wasm != Wasmtime)

[0]: https://github.com/bytecodealliance/wasmtime/issues/10248

[1]: https://github.com/bytecodealliance/wasmtime/issues/12941

[2]: https://github.com/bytecodealliance/wasmtime/issues/12941#is...

[3]: https://github.com/bytecodealliance/wasmtime/issues?q=state%...

Looking at the link, it was quite an eye-opener moment (atleast for me) to see so many language-differentiating features - exceptions, async/await, continuations, generators - can all just be abstracted into one concept called "typed continuations". I'm still wrapping my head around this.

On one hand, I'd assume a "focused" feature, like exceptions, would always be easier to fine-tune and optimize the language, runtime and workflow – rather than generalizing it.

But at the same time, the prospect of saying all those are just special forms of a stacked "yield" (just for my mental model) is quite tantalizing.

  • You might enjoy digging into the world of effect handlers: it's a very neat model for expressing these features and boils down to continuations in the implementation.

  • PL theory seems to be in an infinite loop between arbitrary control flow like call/cc and then realizing it's hard to reason about and restricting it.

    I do wish we could land on a standard model for implementing non local control flow. Like growable stacks.

> Seems like there is still progress

Oh I already know that about WASM now. All is in progress ... perpetual progress.

I'll look again in the next decade.

  • I would suggest you look at it a little more often than that - to improve the quality of discussion here, if for nothing else.