4 ms·
I'm a little bit confused about the notion that composition isn't used much in lisp as opposed to Haskell. Isn't composition literally the benefit of S-express
by ACow_Adonis 6y ago
I'm a little bit confused about the notion that composition isn't used much in lisp as opposed to Haskell.
Isn't composition literally the benefit of S-expressions, prefix notation, and everything being a function?
- smabie 6y agoLisps lack implicit currying, so function composition becomes much more verbose. And functions aren't that important in CL, not everything is a function and CL is usually written in an OOP or procedural style. CL is more about data and AST composition then anything else. Moreover, CL is a lisp-2, so in a very real sense, functions are second class citizens in the language.
- pfdietz 6y agoOr, you use reader macros to make currying concise. https://github.com/eschulte/curry-compose-reader-macros https://github.com/eschulte/curry-compose-reader-macros Functions are not second class citizens. They are privileged with their own namespace. That's a perk, not a penalty. One notable form of composition in CL is method combination. Does any other language support something like that?
- smabie 6y agoHaving to prefix functions with #' is a perk? No other language uses a separate name space for functions, and for good reason, because it sucks.
- pfdietz 6y agoIt's an optimization for usability. Many more symbols occur as the heads of list forms than appear after #'. So, the common case is optimized for clarity and the relatively uncommon case requires two extra characters. I completely disagree that it sucks. What sucks is having to remember not to have your variable names collide with your function names (or indeed any of the other namespaces in CL). Things that are usually used in different ways benefit from having separate namespaces.