On 26/10/16 10:30, Katherine Cox-Buday wrote:
I think this is a hint that this is the wrong approach. The edge-cases begin
showing the cracks in the abstraction and end up making the code more complex.
Consider your example instead of:
var finalResult Foo
for loop := retry.Loop(spec); loop.Next(); {
result, err := SomeFunc(blah)
if err != nil || resultNotGoodEnough(result) {
continue
}
finalResult = result
break
}
There are no special errors, no mixing of concerns, just a boring imperative
loop. It works like any other loop written in Go.
I was trying to reduce the need for continue/break. Forcing
continue/break does not make it like all boring imperative loops.
The err used inside the loop should be declared outside if you want to
be able to see if the loop succeeded or failed.
Tim
--
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/juju-dev