First Draft: Nominal Sum Types via `enum union` and `switch` Expressions

Paul Backus snarwin at gmail.com
Thu Sep 17 12:24:56 UTC 2026


On Tuesday, 15 September 2026 at 22:25:13 UTC, Meta wrote:
> The compiler can lower a switch expression into a jump table, 
> instead of the nested lambda calls of the current library 
> solutions. Even if they're aggressively inlined, there's very 
> little chance they'll get optimized as well as a language 
> construct can be.

I actually tested this a few years back. It turns out that, 
assuming it can inline the callbacks, the compiler can optimize 
`match` just as well as it can optimize a naked `switch` 
statement:

https://pbackus.github.io/blog/beating-stdvisit-without-really-trying.html


More information about the dip.development mailing list