Next up for patterns: type patterns in switch

Brian Goetz brian.goetz at oracle.com
Wed Aug 12 20:05:02 UTC 2020


Since I am always the one saying "state your concern, not your 
solution", let me frame this:

> But i still think having a keyword to signal that a pattern (not a 
> case) is total is better than letting people guess.

 From this I take away that (a) the rules we've proposed for totality vs 
not are mostly OK in terms of their expressiveness and their defaults, 
but (b) you are worried that it is too subtle for Java developers to 
determine whether a given sub-tree of a pattern is total on the part it 
is matching, so (c) you would like some additional assertions to say 
"this is total, error if I'm wrong". These assertions benefit would both 
the writer (to catch errors) and reader (so totality snaps off the page.)

Do I have it right?

But isn't the "switch is total" kind of the half-brother of this story, 
too?  Since statement switches might be total or partial, stating the 
intent would be useful in the same way, right?  (To be clear, I think 
this is two separate issues, but they are related.)




More information about the amber-spec-experts mailing list