[External] : Re: Positioning of guards (was: Reviewing feedback on patterns in switch)
Brian Goetz
brian.goetz at oracle.com
Wed Jan 26 12:35:47 UTC 2022
> For the record: I like the current version with &&. It's short and
> easy to understand (as people already know what && means in Java). I
> see no reason in replacing it with `when`, which is more limiting.
I like the && syntax too (though we can invent some nasty puzzlers with booleans, such as `case false && false`, which are not so likable.) But the two are not uncoupled; its harder to imagine && as part of the case, and not as part of the pattern. We can of course do many things here, but I worry that the choice of operator affects peoples intuition about the semantics. (Historically keyword operators like instanceof have the weakest binding precedence.)
More information about the amber-spec-experts
mailing list