[External] : Re: Remainder in pattern matching
Brian Goetz
brian.goetz at oracle.com
Wed Mar 30 18:52:17 UTC 2022
Yes, and this is a special case of a more general thing -- that while
pattern declarations may have a lot in common with methods, they are not
"just methods with multiple return" (e.g., they have a different set of
characteristics at the declaration, they are intrinsically conditional,
they are "invoked" differently.) While their bodies may look
method-like, and ultimately they boil down to methods, thinking "they
are just methods" is likely to drag you to the wrong place. Of course,
its a balance between how similar and HOW DIFFERENT they are, and that's
what we're looking for.
>> Another thing it gains is that it discourages people
>> from thinking they can use exceptions in dtors; having these laundered
>> through MatchException discourages using this as a side channel, though
>> that's a more minor thing.
> This is a stronger argument than you give it credit for being.
> Wrapping the exception adds a bit of friction to doing the wrong thing
> which will pay off in helping guide users to the intended behaviour.
More information about the amber-spec-observers
mailing list