by bayareanative · 7y ago · 0 comments
In Haskell, you can turn any function into an infix operator with backquotes. As a qualitative, nonfunctional stylistic, ergonomic opinion, I find Haskell much more flexible and beautiful than the ugliness of most brace-, paren- and prolixity-heavy languages. It can present too many features for pragmatic use, orthogonal to something in another domain like Rust or Go for effective software production where features are intentionally constrained or disallowed.
Actually Lisp uses ordinary old polish notation. Reverse Polish Notation is used by stack-oriented systems like HP calculators and Forth.
(- (+ 1 2 3 4 5) 1)
and
- + + + + 1 2 3 4 5 1
The first one seems much more readable to me...
And parentheses don’t serve precisely the same role in Lisp syntax than they in the more free-form world of maths.
One line of code is just enough to get something that works (defmacro infix [a op b] `(~op ~a ~b))
There are libraries for that too. Clojure: https://github.com/rm-hull/infix