4 ms·
The fact that <, >, +, - and other operators are just functions brings alot of benefits. - They are variadic functions, they work on a range of inputs. - Their
by Skinney 13y ago
The fact that <, >, +, - and other operators are just functions brings alot of benefits.
- They are variadic functions, they work on a range of inputs.
- Their names are valid identifiers, which allows for function names like list->vector
- Precense is fairly self-evident. 2 * 2 / 5 - 1 vs (- (* 2 (/ 2 5)) 1). You could add parenthesees to the first, and most would, Lisp just forces you to.
- They are consistent, a function is the first element of a list, no matter what
- Closely related to the above point, they make writing macroes easier. Imagine if macroes had to take infix operators into account. Certain macroes would have to scan the syntax they receive for the presense of operators, or you would have to create special macroes for operators...
- You would need special syntax for passing operators as values to other functions. ((dummy) < 5) ;; What should happen here if dummy returns another function instead of something orderable?