Danny Potter
Danny Potter

Reputation: 11

named loops in Julia

in Fortran there are Named Loops but I have not found this function in Julia. Is there a way to do named loops? So that the compiler checks if the end statement corresponds to the correct loop start? Thx for help

For example:

counting: for i = 1:5  
    println(i)  
end counting

Upvotes: 1

Views: 281

Answers (1)

Bill
Bill

Reputation: 6086

No, this is not a feature, but, instead, the compiler tracks nested loops to allow nested end statements. In addition, there are break, continue, and and try/catch features of the language to do, generally more easily, what naming loops usually do in Fortran. Leaving out a nested end statement with nested loops will generate a syntax error by the compiler.

https://docs.julialang.org/en/v1/manual/control-flow/index.html#man-loops-1

Upvotes: 3

Related Questions