Expression switch exception naming
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Mar 28 19:44:20 UTC 2018
My point was more that if you want an exception and not an error,
you can add a default than discussing the merit of implicit vs explicit throwable.
The compiler should emit a code that throw an error for unknown enum constant.
if the compiler emit a code that throw an exception,
people will also be able to catch it, adding another way to react to a missing enum constant.
regards,
Rémi
----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Gavin Bierman" <gavin.bierman at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Mercredi 28 Mars 2018 20:55:04
> Objet: Re: Expression switch exception naming
>> Using a runtime exception is like another less readable way to do exactly that.
>>
>>
>
> It's both less and more readable.
>
> Its less readable in that its implicit in the code, rather than
> explicit. But its probably the case that the exception thrown
> implicitly will be more informative to the user than the hand-written
> one, which is usually:
>
> default: throw new AssertionError("can't get here");
>
> Which is less readable for the poor fellow who had to debug it.
More information about the amber-spec-experts
mailing list