Treatment of nested 'break'
Brian Goetz
brian.goetz at oracle.com
Wed May 9 01:16:13 UTC 2018
> I am concerned about the treatment of 'break' statements in switch expressions. The following seems like something that would be very natural to do:
>
> boolean x = switch (expr()) {
> case FOO -> {
> for (String s : strings) {
> if (s.isEmpty()) break false;
> }
> break true;
> }
> case BAR -> true;
> default -> false;
> };
This should be valid. If you recall the table I posted regarding abrupt completion, the for-loop should be transparent to “break val”, in the same way it is transparent to “return” or “throw” or that block expressions are transparent to all abruptly completing statements. The constraint on “case Foo -> { … }” is that the block must complete abruptly via break-value.
More information about the amber-spec-experts
mailing list