To Kortschak and all others participating in this debate : Please don't get hung up over my choice of symbol '?' . My choice of symbol '?' and ';' is causing people to equate my proposal with a proposal to adopt C's ternary operator in Go. This is not what I intended to propose.
My proposal regarding ? test {...} : {.. } in is nothing more, nothing less than a replacement for if (test) { ... } else {... } i.e. 'if' and 'else' are replaced by symbols '?' and ';' .. For example I propose that a statement like ? (x >-1) { y=x; z= x*x } : { y=x*x; z= y } compile in Go EXACTLY THE SAME way that Go currently compiles the same statement with symbol '?' replaced by 'if' and ';' replaced by 'else' . Currently, neither C++, C nor Go will compile the above statement The second part of my proposal called for allowing statements like x = (test) ? 1 : 0 to compile in Go. C will currently compile this statement but Go will not. But I stress again, I intended Go to compile this statement exactly the same way it compiles if (test) { x=1} else { x=0 } AND that no nested '?' symbols are allowed in a single assignment statement. In short, I'm proposing a cleaner way to write Go 'if' 'else' statements, nothing more, nothing less. If anyone can offer a concrete example of how my proposed statement will cause problems in Go, just replace my chosen symbol '?' with 'if' and symbol ';' with 'else' and you'll have a statement that will currently compile in Go (and cause the same problems) .. On Thursday, April 25, 2019 at 5:15:23 PM UTC-4, kortschak wrote: > > The difference is that the ternary operator is an expression and the > if...else is a statement. If you're only suggesting a syntax change, > then the difference becomes one of readability. > > I'll ask again, how would you preclude nesting without making the > language more complex? > > On Thu, 2019-04-25 at 13:38 -0700, lgo...@gmail.com <javascript:> wrote: > > Rob: > > > > Am I missing something ?? > > The proposed syntax > > test ? { > > } : { > > } > > > > with no-nesting allowed is equivalent to > > if test { > > //..... > > } else { > > // .. > > } > > ..The former is just a cleaner way of writing the latter > > > > Any complaints regarding 'abuse' associated with the former equally > > apply > > to the latter > > > > On Thursday, April 25, 2019 at 11:47:21 AM UTC-4, Rob 'Commander' > > Pike > > wrote: > > > > > > > > > I am pretty sure that the decision not to have ?: in Go was a > > > unanimous > > > decision by Robert, Ken and myself after almost no discussion. It > > > is too > > > easy to abuse, as the FAQ states. > > > > > > -rob > > > > > > > -- 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.