4 ms·
In the back of my mind I'm wondering whether regular parentheses couldn't incorporate the curly infix syntax. In particular, a Lisp-2 helps here. Suppose we ha
by kazinator 2y ago
In the back of my mind I'm wondering whether regular parentheses couldn't incorporate the curly infix syntax.
In particular, a Lisp-2 helps here. Suppose we have (x + y). If that is interpreted as arguments + y passed to function x, it makes no sense. There is no such function, and + has no variable binding. So we can take the second interpretation: swap the first two positions.
Even in a Lisp-1, we can simply have a rule that if the second position of a funcion call is the member of a set of math operators (which could be by symbol identity, without caring about the binding), we do the swap.
The users then just can't use + as a variable name in the second position of a function call.
This swap can be done during the macro-expanding code walk, so the interpreter or compiler only see (+ x y), just like with brace expressions.