[External] : Re: Two new draft pattern matching JEPs

Gavin Bierman gavin.bierman at oracle.com
Thu Feb 18 14:41:32 UTC 2021


Ha! I’ll change the example.

Thanks,
Gavin

> On 18 Feb 2021, at 12:52, Tagir Valeev <amaembo at gmail.com> wrote:
> 
> Hello!
> 
> Thank you!
> 
> There's a sample in Nested Record and Array Patterns draft:
> 
> static void printColorOfUpperLeftPoint(Object o) {
>    if (o instanceof Rectangle(ColoredPoint ul, ColoredPoint lr)){
>        if (ul instanceof ColoredPoint(Point p, Color c)) {
>            System.out.println(c);
>        }
>    }
> }
> 
> It looks like here, the nested pattern "ul instanceof
> ColoredPoint(Point p, Color c)" is total. I thought that there's idea
> to prohibit total patterns with instanceof (at least total type test
> patterns are already prohibited). Please correct me if I'm wrong.
> 
> With best regards,
> Tagir Valeev.
> 
> On Thu, Feb 18, 2021 at 7:33 PM Gavin Bierman <gavin.bierman at oracle.com> wrote:
>> 
>> Dear all,
>> 
>> The next steps in adding pattern matching to Java are coming! I have drafted two new JEPs:
>> 
>> - Nested Record and Array Patterns: https://bugs.openjdk.java.net/browse/JDK-8260244
>> 
>> - Pattern Matching for switch: https://bugs.openjdk.java.net/browse/JDK-8213076
>> 
>> We split them up to try to keep the complexity down, but we might decide to merge them into a single JEP. Let me know what you think.
>> 
>> Draft language specs are under way - I will announce those as soon as they are ready.
>> 
>> Comments welcome as always!
>> 
>> Thanks,
>> Gavin



More information about the amber-spec-experts mailing list