JEP 443: semantics of "case _" vs "case null, default"
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed May 17 15:58:58 UTC 2023
----- Original Message -----
> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>, "amber-spec-experts" <amber-spec-experts at openjdk.org>
> Cc: "Gavin Bierman" <gavin.bierman at oracle.com>
> Sent: Wednesday, May 17, 2023 5:25:57 PM
> Subject: Re: JEP 443: semantics of "case _" vs "case null, default"
> On 5/17/2023 8:33 AM, Remi Forax wrote:
>> Hello, all,
>> I've reread the JEP 443,
>> https://cr.openjdk.org/~abimpoudis/unnamed/jep443-20230322/specs/unnamed-jls.html
>>
>> First, a minor nit, at the end of the section 14.30.1, there is this sentence
>> that reference the section 14.30.1 !
>> "An unnamed pattern is always null-matching (14.30.1)."
>>
>> My brain, stackoverflowed on that :)
>
> This is a minor shuffling of terminology, but nothing really has changed.
>
> Previously we recorded the difference between a partial and total type
> pattern (which differ at their null matching) through a process of
> resolving an unconditional pattern to an "any" pattern. The any pattern
> was a figment of the specification, and didn't correspond to anything in
> the language (yet). Now that we have underscore patterns, which might
> well be called "any" patterns, the terminology was confusing so we
> adjusted the terms, to those that will likely serve us better in the
> future. But the semantics are still what they always were.
>
>> And now a question, with the introduction of the unnamed pattern, in a switch,
>> "case _" and "case null, default" have the same semantics,
>> given that "case null, default" is a kind of a hack, should we still allow it ?
>>
>
> This is actually two questions:
>
> - should we still allow `case null, default` (current answer: yes)
> - should we allow `case _` (current answer: no)
>
> If the answer to the second is no, there is no question that we should
> continue to say yes to the first.
>
> I think given the long history of null-hostility of switch, giving
> people both `case _` and `default` at the top level will make more
> trouble than it solves, so the status quo seems OK to me.
So like "case var o" is not allowed.
It's OK for me too, I did not know (or forget) that case _ was not allowed.
Rémi
More information about the amber-spec-experts
mailing list