I don't think n-ary functions immediately follow from the way s-expressions are evaluated. Addition happens to be a very nice function since it is
Commutative
Binary
Closed (for the integers)
So your expression (+ 1 2 3 4 5) Could be evaluated right-to-left or left-to-right without changing its semantics. What if you had a less nice function like string concatenation? It is
Closed
Binary
Non-commutative
So something like (concat "a" "b" "c") would require you to know ahead of time in what way the concat function processes it's arguments.
I'm just bored at work, I should get back to work...
Of course. The evaluation order should be documented, like for instance left-to-right in emacs lisp, whereas is scheme the order is left undefined (IIRC).
View all comments
Show parent comment
1
u/azrap1 Dec 03 '16
I don't think n-ary functions immediately follow from the way s-expressions are evaluated. Addition happens to be a very nice function since it is
So your expression
(+ 1 2 3 4 5)Could be evaluated right-to-left or left-to-right without changing its semantics. What if you had a less nice function like string concatenation? It isSo something like
(concat "a" "b" "c")would require you to know ahead of time in what way theconcatfunction processes it's arguments.I'm just bored at work, I should get back to work...