Updated patterns-in-switch doc
Brian Goetz
brian.goetz at oracle.com
Sun Sep 13 22:23:33 UTC 2020
I find these arguments not-remotely-compelling. Variable declarations
should look like declarations; it is highly error-prone to have the mere
mention of a name cause it to spring into being. I see no value, and
much anti-value, in having `Point(x)` introduce a new variable x.
So, no. I think that would be a very bad idea.
On 9/13/2020 3:10 PM, forax at univ-mlv.fr wrote:
>
>
> ------------------------------------------------------------------------
>
> *De: *"Brian Goetz" <brian.goetz at oracle.com>
> *À: *"Remi Forax" <forax at univ-mlv.fr>
> *Cc: *"amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> *Envoyé: *Dimanche 13 Septembre 2020 20:34:54
> *Objet: *Re: Updated patterns-in-switch doc
>
>
> 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.
>
>
> The main issue i see with using var is that when you have nested
> patterns, "var" starts to becomes noise because you start to have
> several of them, so it makes the nesting less obvious.
> For me, var is good the first times to see how pattern matching works,
> it's very similar how as a beginner you are prefixing everything with
> "this" but after some times, it falls into the noise category,
> that why i'm not proposing to not allow "var" but to allow to not use
> "var".
> Again, this is very similar to the things we were discussing during
> the conception of lambdas, should we try to protect them with a lot of
> syntax to say, this is the new thing or should we try to make the
> syntax simpler with the risk of people not understanding it.
>
> Rémi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200913/35c0d453/attachment.htm>
More information about the amber-spec-experts
mailing list