We definitely want to get into that! Unfortunately it's not completely straightforward. A simple desugaring doesn't work due to our support for intermediate bindings and computations, which we don't want to recompute.
Re:The Ultimate Conditional Syntax
by HelloNurse on Monday October 21, 2024 @11:16AM
(#41905096)
Do you mean something like compiling
if (x is Left(Foo(y)) or x is Right(Foo(y))) and (y<5 or z>2) then 5
and destructuring Foo(y) only one time and dealing with parentheses?
Imagine Left and Right contained data of compatible types, then I'd like to extract that data (regardless of tag) like so:
That way I only need to write the `...` part once. (This could be combined with the rest of the pattern matching machinery in interesting ways, and would probably need to have eager matching / short-circuiting semantics in case both cases match).