3 ms·
Using the same notation for function calls and math operators has many benefits that may not be immediately obvious, and which may (depending on preference) out
by widdershins 2y ago
Using the same notation for function calls and math operators has many benefits that may not be immediately obvious, and which may (depending on preference) outweigh the unfamiliarity. For example:
No operator precedence rules to remember.
Use math operators in higher order functions:
(reduce [1 2 3] +)
(compose + \*)
Simpler parser in the language.
Use kebab-case variable names.
Use most symbols in variable names.
The last two are because of reduced ambiguity in the language.
The benefits for readability can be huge.
For example, I love question marks for predicates in Scheme.
(vector? x)
(filter [1 2 3 4 5] odd?)
I'm sure there are more benefits that I haven't thought of.
- ReleaseCandidat 2y ago> Use math operators in higher order functions: To be fair, there just needs to be syntax for passing infix functions as a "normal" function, like parens in Haskell (reduce [1 2 3] +) foldl' (+) 0 [1, 2, 3] And to allow `?` in names, it "just" shall not be used elsewhere.