On Wed, May 2, 2018 at 11:48 AM Hugh Fisher <hugo.fis...@gmail.com> wrote:
> 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. > Note, that switch as a statement *does* add significant power to the language, so this comparison is only about the statement "A missing switch expression is equivalent to the boolean value true" from the spec - which IMO is pretty low-impact, it doesn't add any keywords and just a pretty simple alternation to the grammar to make a specific identifier optional. I also think "you can replace construct A by construct B" isn't really the same as saying "construct A does not add any power over construct B". By that logic, loops and conditionals wouldn't really add any power to a language, as they can be replaced by a label and a goto. And as others have pointed out, a do-while loop *would* add some more power to the language. What you propose, though, doesn't seem to: The simplest way to introduce it, would be to recognize a new keyword "while" that is an alias of "for" (and parses to the same AST). In my opinion, a simple substitution of a keyword does not qualify for "adding power" (and I acknowledge that the edges are fuzzy here). 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. > -- 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.