On Jan 8, 2020, at 12:27 PM, Brian Goetz <[email protected]> wrote:
> 
> So, summary:
>  - the null constant pattern matches null;
>  - "any" patterns match null;
>  - A total type pattern is an "any" pattern;
>  - var is just type inference;
>  - no other patterns match null;
>  - existing constructs retain their existing null behaviors.  

FWIW, I love this, because (a) it gives null a little niche
at the top (case “any") and bottom (case null) of the lattice
of patterns, and (b) it collapses two useful surface forms
of patterns into one essential kind (“any”).

I think, and have argued elsewhere, that although type
inference in general risks being a confusing “action at a
distance” phenomenon, this use of total type patterns
is constrained enough to be easily readable in normal
usage.  (Hint:  The total type pattern is constrained to
be the last one.  So the type, if not “var”, is really just
a way of documenting the switch type.)

— John

Reply via email to