Pattern matching: next steps after JEP 405
forax at univ-mlv.fr
forax at univ-mlv.fr
Fri May 20 05:27:28 UTC 2022
> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Sent: Thursday, May 19, 2022 3:05:07 PM
> Subject: Re: Pattern matching: next steps after JEP 405
>> When you have a type pattern X in a middle of a pattern *and* you have
>> conversions, then there is an ambiguity,
>> does instanceof Box(X x) means
>> Box(var v) && v instanceof X x
>> or
>> Box(var v) && X x = (X) v;
> This is not an ambiguity in the language, it is confusion on the part of the
> reader :)
> In any case, I'm not following your argument here.
If you have both a type pattern and allow conversions, you have
Box(X) is equivalent to Box(var v) && v instanceof Y y && X x = (X) y
How do you find Y ?
And yes, the bar is not only that Y has to be unique for the compiler, it has also to be obvious for the human reader too.
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220520/745bc40d/attachment-0001.htm>
More information about the amber-spec-experts
mailing list