You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We actually have an or-pattern constructor internally. I think it's just a question of writing an elaboration pass that removes it, as not all our theorem prover targets support or-patterns.
Probably the simplest re-write is into guards:
match head {
a | b => exp1,
c => exp2
}
becomes
match head [
d if match d { a => true, b => true, _ => false} => exp1,
c => exp2,
}
Rust and OCaml, and I assume other languages that support Sail's style of pattern matching let you have multiple patterns for one match branch:
It would be nice if Sail supported this. Not a major issue at all but I and a few other people have been slightly caught up by it a few times.
Also I dunno if I like the
|
syntax because it has such strong ambiguity with bool/bitwise or. Like, this code is not obvious:Does that mean it will match
a
orb
, ora bitwise_or b
? I would suggest using a comma if possible:Maybe slightly unexpected to people familiar with Rust/OCaml/etc. and it does have potential confusion with tuples, but I reckon it's still better.
The text was updated successfully, but these errors were encountered: