Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: Go 2: extend "continue" to jump to start of function #34144
continue statement begins the next iteration of the innermost "for" loop at its post statement. The "for" loop must be within the same function. If there is a label, it must be that of an enclosing "for" statement, and that is the one whose execution advances.
In addition to the above officially specified definition of continue keyword, I am proposing to extend its definition to also include the containing function body as the outer-most layer. That means:
I occasionally find myself using
Note: When examining this, I realized we can create labels inside functions with the same name. So you can have a label
Note 2: Since we have return, we don't need to change anything about "break".
Within a loop,
It also doesn't seem like something that comes up all that often. In https://blog.golang.org/go2-here-we-come Robert outlined three criteria for language changes. I'm not sure this meets criteria 1: address an important issue for many people.