Clearly accessing locals should be allowed, to some degree -- it would
be weird if we could not reference y here. But it is reasonable to ask,
what restrictions do we want to place? Are the same restrictions as
lambdas -- effectively-final only -- too restrictive? (Certainly such a
restriction opens up more options for translation strategies, and is
consistent with other -> contexts.)
On 12/7/2017 6:02 PM, Remi Forax wrote:
Hi Brian,
correct me of i'm wrong but there is no discussion about accessing to a local
variable in the body of an expression,
void m(int x, int y) {
return switch(x) {
case 0 -> y; // is it allowed, how is it translated ?
default -> 0;
};
}
regards,
Rémi
----- Mail original -----
De: "Brian Goetz" <[email protected]>
À: "amber-spec-experts" <[email protected]>
Envoyé: Jeudi 7 Décembre 2017 23:33:36
Objet: New JEP: Switch Expressions for the Java Language
We've separated out a package of standalone improvements to `switch`
(switch expressions, case null, and case alternation) into their own JEP:
https://bugs.openjdk.java.net/browse/JDK-8192963