3 ms·
It's perhaps a little confusing when first learning Lisp, but once you've got the hang of things, working out the precedence of operations is really easy. In m
by ldjb 10y ago
It's perhaps a little confusing when first learning Lisp, but once you've got the hang of things, working out the precedence of operations is really easy.
In most programming languages with infix operators, the precedence often depends on the operators themselves. For example, with:
5 + 3 * 10
...You'd need to know that * has higher precedence than + to figure out the value of this expression is 35, not 80.
But with the following Lisp expression:
(+ 5 (* 3 10))
...The syntax itself tells you the precedence, so there's no ambiguity. Even if you didn't know anything about the functions involved:
(bar 5 (foo 3 10))
...You don't need to worry about whether foo has precedence over bar or the other way round -- there's only one way to evaulate the expression.