Skip to content

Conversation

@egranata
Copy link
Collaborator

Fixes #84

@egranata
Copy link
Collaborator Author

This change does not compose well, for example one cannot do

val maybe = Maybe::Some(5);

if case Some(n) = maybe && n > 3 { ... }

or even just if maybe isa Maybe and case Some(n) = maybe { ... }

so this syntax seems more ergonomic but it composes poorly, i.e. not at all, is prone to raising runtime errors (e.g. if case Foo = 3) without a clean simple syntax to avoid that, and it also does not compose well with multiple values, e.g.

val a = Result::Ok(3);
val b = Maybe::Some(4);

if case Ok(val_a) = a and case Some(val_b) = b { ... }

to be fair, match also does not do a good job of the latter as there is no way to match on a list of elements and pattern match only some/all of them to something

The long and short of it is, this syntax is not a simple composable block, but rather some ad-hoc piece of machinery, and it is not obvious to me that it carries its weight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

if val syntax

3 participants