Updated patterns-in-switch doc

Brian Goetz brian.goetz at oracle.com
Sun Sep 13 18:34:54 UTC 2020


>     I don’t quite get the leap from “no constant patterns” to changing
>     the syntax of deconstruction patterns, but in any case, we
>     definitely don’t want this (and in fact, for the same reasons
>     cited in the section on constant patterns, and others.)
>
>
> if case Point(x, y) can not mean instanceof Point p where p.x == x && 
> p.y == y, then case Point(x, y) can have the same meaning has a lambda 
> (x, y), introducing two fresh variables x and y.

If you're making the claim that "It would not be disastrously 
inconsistent for it to work that way", I agree.  But I think it would 
still be quite foolish of us to go that way anyway.  The benefit is tiny 
(a few fewer characters typed) at a very considerable cost -- reduced 
readability, and potential ambiguities.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200913/821625c5/attachment.htm>


More information about the amber-spec-experts mailing list