New JEP: Switch Expressions for the Java Language
forax at univ-mlv.fr
forax at univ-mlv.fr
Mon Dec 18 21:41:12 UTC 2017
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Kevin Bourrillion" <kevinb at google.com>
> Cc: "Remi Forax" <forax at univ-mlv.fr>, "amber-spec-experts"
> <amber-spec-experts at openjdk.java.net>
> Envoyé: Lundi 18 Décembre 2017 22:25:15
> Objet: Re: New JEP: Switch Expressions for the Java Language
> On 12/18/2017 4:16 PM, Kevin Bourrillion wrote:
>> On Mon, Dec 11, 2017 at 11:28 AM, Brian Goetz < [ mailto:brian.goetz at oracle.com
>> | brian.goetz at oracle.com ] > wrote:
>>>> I think most of my questions surround how these changes will (or should ) affect
>>>> non-expression switches.
>>>> * Should we retcon `case A, B:` onto regular switches, with the same semantics?
>>> Absolutely; I thought this was already present in the JEP, but if not, I'll
>>> clarify.
>>>> * Should we retcon `case null:` onto regular switches, with the same semantics?
>>> Absolutely; same comment.
>> There is a problem here, especially among users who learn Java in the future and
>> never know how `switch` used to work.
>> They will know that `null` is a valid thing to switch on, and when they don't
>> see `case null` they will assume that the `default` clause is being executed.
>> That's unfortunate.
> Why would they assume that? What they'll learn in future Java school is "If
> there's no explicit case null, switch throws NPE". Which is exactly as it is
> today -- except that you can't spell "case null". In no case will a switch
> without a "case null" execute the default clause on null input.
yes, this is how i will teach it :)
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20171218/a4442cd3/attachment.html>
More information about the amber-spec-experts
mailing list