On Wednesday, 15 August 2018 13:23:36 UTC+2, Mark Volkmann wrote:
>
> [...]
> The first is ternaries. What if only simple, non-nested ternaries were 
> supported? For example, color := temperature > 100 ? “red” : “blue”. 
>

It is easy to write "non-nested" but it is hard to define.
Probably a?(b?c:d):e is "nested" but:
Is f(a?b:c) a nesting of ?:
Is g(a?b:c, d?:e:f) nested?
It gets ugly very fast.

And: Your example looks innocent, but requirement never
stay innocent. In 6 month you will have to encode 3 temperature
ranges in red, green and blue and you will have to replace the
?: with if/else if/else or a switch anyway. So why not start out
directly with an if?
 

> [...]
>

I personally doubt that adoption per se is a goal. And if than
Go's adoption is perhaps driven by actual absence of this
syntactical sugar. Especially complicated syntactical sugar like
ternary ?: is fine but not nested!

V.

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