Closed
Description
This is an unnecessary corner of the language, the only remaining use of the check
keyword. I know I have misexplained the difference between alt
and alt check
before.
alt check
is a bit of an anti-pattern because it:
- Indicates that enums aren't factored correctly. With case classes we should have more control to prevent this kind of problem.
- Encourages non-exhaustive matches which are only discovered at runtime.
- Doesn't provide any documentation about why other cases don't matter.
Which is clearer?
alt check foo {
bar => baz
}
alt foo {
bar => baz,
_ => fail "this shouldn't happen because ..."
}
The first requires explaination. The second says exactly what the fallthrough behavior is, occurs syntactically where the fallthrough behavior occurs, and is more natural to write (once you've written all the cases you intend to cover you then write the fallthrough case instead of going back to the top of the structure and changing it).