On Sat, Sep 20, 2025, 11:41 AM Stephen Illingworth <
[email protected]> wrote:

> 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.
>

Apologies for misunderstanding.

Since the most common case for a labeled break is nested for loops,
personally I don't think the benefit here is worth the language
complication.

Ian

>

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV%2BANzp5a%3DBgJGhVNWppnTNSmELkm9tQ-6X_Cu8oaN%2Bmg%40mail.gmail.com.

Reply via email to