goto
statements can sometimes be useful to go down (to lower lines of code) in code, but can create a mess if used to go up (to higher lines of code). Therefore, I am wondering if there is any language that only allows goto
statement to go down, e.g, godown
.
Edit:
My main motivation for asking this question is this question Why does Go have a “goto” statement
I feel like if designers of a modern language like go
decided to use goto
statement there is a place for it. Also, as pointed out in one of the answers to the question, goto
are used in go
source code.
When I said "create a mess", I was referring to something like this, in a more complicated scenario:
package main
import "fmt"
func main(){
i := 0
back:
i++
fmt.Println(i)
if i < 10 {
goto back
}
fmt.Println("we are finished")
}