Recognizing this is likely to be a dead horse already flogged to infinity,
I've been unsuccessful trying to find discussions on the topic of why while
was nixed in-favor of the more verbose and error-prone for-based
implementations, hoped someone could furnish links?
c.f
// concise, non-repetitive, positively-expressed continuation-clause:
while n := parser.Next(); isAlpha(n) {
// .. use of n ..
}
vs
// compact but duplicative.
for n := parser.Next(); isAlpha(char); n = parser.Next() {
// .. use of n ..
}
// otherwise; negated logic to express the 'break' up-front
for {
n := parser.Next()
if !isAlpha(n) {
break
}
// .. use of n ..
}
// or additional nesting and "break escape" risk to express positively
for {
if n = parser.Next(); isAlpha(n) {
// .. use n, make sure you remember to continue ..
}
break
}
//or; negated logic
var n rune
for {
if n = parser.Next(); !isAlpha(n) {
break
}
// .. use of n ..
}
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/18ce083c-d332-4ee2-b72b-d31263168d46n%40googlegroups.com.