Treatment of nested 'break'
brian.goetz at oracle.com
Thu May 10 19:06:47 UTC 2018
> I think these are both valid explanations, with different outcomes, but anyway it's fair to say that it would be confusing to have the latter perspective and then try to explain how a value break can get past a surrounding 'for' loop.
One option is: you can't. While I agree there is code that one might
like to write that is made cumbersome by this, it's a valid option, and
not one that is utterly terrible.
Another option is to extend the break syntax along the lines of the
proposed continue syntax. Suppose for every continuable construct x
(for, while, switch) we supported "continue x". So for every breakable
construct y we could support "break y". If a for loop were enclosed in
an expression switch, you could then say "break switch e". Then
break switch 3;
and it is much more obvious what is going on.
More information about the amber-spec-experts