Reviewing feedback on patterns in switch

Brian Goetz brian.goetz at
Wed Jan 26 15:42:23 UTC 2022

To summarize the feedback so far (please, don’t reply here, use the threads): 

> 1.  Treatment of total patterns in switch / instanceof

There seems to be overall inclination to adjust semantics of *switch* (not patterns) to be more in line with historical switch behavior.  This could be summarized as “if you want null, say null”, at least for switch, which we can justify because switch has a historical hostility to null.  The cost is that refactoring / code transform will be slightly less transparent.  Would be great to have a catalog of these.  

> 2.  Positioning of guards

There were two points here: whether a guard is attached to a pattern or to a case, and secondarily, how we denote a guard.  There seems to be overall agreement so far that attaching to the case is preferable; there is not yet agreement on syntax.

> 3.  Type refinements for GADTs

There’s some general feeling that we have a problem that needs to be solved, but some diffidence about refining type variables as a result of pattern matching.  

> 4.  Diamond for type patterns (and record patterns)

No one seems to object to the notion of diamond in patterns.  Some questions about “why didn’t we do implicit diamond” (as we did with method references.)  Some questions about “are there other contexts we should be doing this in."

So far we’ve heard from Remi and Tagir.  Would like to hear from others.  

More information about the amber-spec-experts mailing list