4 ms·
Why not have if/else be an expression in the first place, like Kotlin? n = if(expr) trueVal else falseVal No need to learn a separate ternary operator.
by Felz 8y ago
Why not have if/else be an expression in the first place, like Kotlin?
n = if(expr) trueVal else falseVal
No need to learn a separate ternary operator.
- yashap 8y agoQuite a few languages do if expressions, and IMO they’re great. Simple syntax, readable and powerful. It’s crazy to me that any new language wouldn’t have them.
- candiodari 8y agoThe argument specified in the docs is "a language needs only one conditional flow construct" (in a language, of course, that has half a dozen conditional flow constructs ...) The more palatable argument that people who try to cover for ... seems to be that when people nest if expressions, it becomes a mess. I'm glad these people exist. The real reason is found here: http://dtrace.org/blogs/wesolows/2014/12/29/golang-is-trash/ http://dtrace.org/blogs/wesolows/2014/12/29/golang-is-trash/ (or if you prefer, in the compiler's source itself. It doesn't take a compiler expert to realize it's not very clean code. Even violates the go style, and the C one before that was just horrendous) The TLDR is that Go's compiler is a "fisher-price my first compiler" and really shows that the authors simply barely knew how to get a compiler working in the first place. That they were not ready to go into a rational discussion on programming language and type theory ... is not something anyone should be surprised about. That they avoid the arguments by dismissing the people making them in such a condescending way is ... well, there's not really anything good to say about that.
- 4ad 8y agoKen Thompson has been writing compilers for over 50 years now. If you believe that Ken "barely knew how to get a compiler working in the first place", we have nothing to talk about, as you obviously made up your mind already.
- candiodari 8y agoThen read the source for the compiler yourself. Tell me I'm wrong.
- 4ad 8y agoNot only I have read it, I have written several compiler targets for it. You are wrong. It's by far the easiest compiler I have worked with.
- iainmerrick 8y agoBecause the designers of Kotlin are more open to experimentation and new ideas.
- erik_seaberg 8y ago(setq n (cond (expr trueVal) (t falseVal))) This particular idea dates back to at least 1965.
- iainmerrick 8y agoEr, yes, I should say “new ideas about which features are worth stealing from Lisp” :)