Re:Why didn't Common Lisp fix the world?
by kiiski on Tuesday May 17, 2016 @08:37AM
(#11713051)
Your example is also misleading. The `a` and `expr` are written as variables in the left example, but as function calls in the Lisp version. More correctly it would be either
Or
Now the amount of parentheses is either 4/6 or 8/10 which is not a very big difference (and caused only by the syntactic sugar for `not`), especially considering that the left example uses `!`, `&&` and two kinds of parentheses (perhaps a `;` as well).
[ Parent
| on HN ]
You're absolutely right, I didn't know the difference between "a" and "(a)", sorry.
My point was more about the two extra parentheses for each && or ||. Imagine converting
if (a && b && c && d || e)
to a LISP.
Re:Why didn't Common Lisp fix the world?
by likeclockwork on Tuesday May 17, 2016 @09:23AM
(#11713385)
if (a && b && c && d || e) {
doSomething();
}
becomes (if (or (and a b c d) e)
(doSomething))
It's just a little more explicit because operator associativity and precedence aren't worked out for you. (For better or for worse.)EDIT: I think you were imagining something like this:
(if (or (and a (and b (and c (and d)))) e)
(doSomething))
..which is definitely not the art.Adding to this, in a real situation those variables are probably not going to be nice single letter variables. With longer names the Lisp syntax with unambiguous structure/order of precedence becomes much nicer.
(if (or (and foobar
(some-predicate-p quux)
(= qwerty 432))
(a-long-function-call-with-two-args bar ytr))
...)
Compared to something like: if (foobar &&
somePredicate(quux) &&
(qwerty == 432) ||
aLongFunctionCallWithTwoArgs(bar, ytr)) {
...
}