On Saturday, 8 October 2016 20:19:37 UTC+1, Egon wrote:
>
>
>
> In this code you could use empty blocks, e.g.:
>
> {
> i := 0
> loop:
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>
> or:
>
>   i := 0
> {
> loop:
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>
> or:
>
> i := 0
> loop:
> {
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>

Yeah I somehow forgot I could arbitrarily use brackets for scope (and fmt 
indentation) - I guess the "i" should be local to the loop so the first way 
seems to make the most sense.

In the short loop case the 'goto' form is much faster (2x) than the one 
with the boolean, and about the same as the example with the break 
conditions in the second if - which reads ok.

I suppose a go-ish form of repeat-until or do-while would look something 
like this

repeat i := a.X {

repeat j := a.Y {

repeat k := a.Z {


//fmt.Println(" xyz ", i, j, k)


} until k == b.Z; k = k + b.Z - a.Z

} until j == b.Y; j = j + b.Y - a.Y

} until i == b.X; i = i + b.X - a.X


 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to