On Tuesday, May 1, 2018 at 10:45:30 PM UTC+10, Ian Lance Taylor wrote:
>
>
> A `while` statement would presumably be exactly identical to a `for` 
> statement with a single condition.  So adding a `while` statement 
> would not add any power to the language, and would add an additional 
> keyword.  All language choices are a cost benefit decision.  In this 
> case the benefit is a looping construct that some people will find 
> clearer to read and write, and the cost is a new keyword that 
> everybody needs to learn, and that at this point in the language's 
> evolution will likely break some, even if not much, existing code.  I 
> don't think the benefit is worth the cost. 
>
> As for not adding any power, that's why I mentioned if-then-else and 
switch.
Switch with boolean cases is the same as if then else. It's not an obscure
side effect either, the Go Tour cheerfully explains how to use it instead of
if-then-else if you prefer.

It's not a new keyword to learn unless Go is your only programming language
and you're never intending to use anything else. "while" has been a reserved
word in Algol/Pascal family languages for 50 or so years, and in C/C++/Java
family languages for over 40 years.

Which is why I don't think it's going to break anyone's code. It's not a 
name
that anyone with experience in other languages is going to use, and it's not
even a natural identifier for those who've never used those other languages
either, while being neither a noun nor verb.

I did a search on go.googlesource.com/go for "while". Turned up a few C
loops, some Python code in a string literal 
src/runtime/runtime-lldb_test.go,
and some Emacs Lisp code in misc/emacs/go-mode.el.

Not one single use of 'while' as an identifier in Go code. Nearest thing is 
a
function scanWhile in src/encoding/json/decode.go. OK it's not all the Go
code in existence, but I think a strong hint that Go programmers don't want
to use while as an identifier.

Hmm, think I will have a look at the formal change proposal process...

cheers,
Hugh Fisher

-- 
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