--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/e8d9bd75-44fe-4280-a550-772efc6c32fbn%40googlegroups.com.
My recollection is that we discussed how to handle an unlabeled break statement in a select statement. Should it break out of the select or should it break out of the enclosing loop? We wanted break in a switch to break out of the switch, not the loop, to be less confusing to C programmers. And select and switch look pretty similar on the page. Handling break the same way for both seemed to make the most sense.
I'm suggesting that there might be a way of implicitly labeling the nearest loop. For example:for {
switch rand.IntN(3) {
case 0:
case 1:
break for
case 2:
}
}At the moment, you have to explicitly define the label:func main() {myloop:for {
switch rand.IntN(3) {
case 0:
case 1:
break myloop
case 2:
}
}}This works and there's nothing wrong with it, but maybe there's a case for the implicit form too.I recognise that there are yet other ways of dealing with the problem, but the 'implicit label' seems like a neat solution to me.