[pattern-switch] Exhaustiveness

Brian Goetz brian.goetz at oracle.com
Thu Aug 20 20:37:24 UTC 2020


> but it doesn't mean that in term of translation strategy we need all 
> those cases as synthetic cases, installing some null checks upfront 
> (of a pattern deconstruction) and a default should be enough, or am i 
> missing something.

They don't have to be implemented as individual synthetic cases, but it 
is a reasonable mental model for purposes of discussing what should happen.

But, depending on what mapping we make between the residue and 
exceptions to be thrown, "null check + default" may not be a 
sufficiently rich model.  (It was for enums, but the shape of the 
residue is more complicated here.)  If our residue is null, and 
Box(null), Box(novel), and we want want to extrapolate from the 
exception rules we have for enums, then we are throwing different things 
for Box(null) and Box(novel).  Which is why synthetic cases might be a 
more accurate starting point; we can express Box(null) and Box(novel) as 
patterns.




More information about the amber-spec-experts mailing list