3 ms·
I'm not sure I understand the question. You can write CLOS code in a pure-functional manner, or you can choose not to. Generic-functions are, in general, more
by aidenn0 6y ago
I'm not sure I understand the question. You can write CLOS code in a pure-functional manner, or you can choose not to.
Generic-functions are, in general, more useful for some types of functional programming than the typical single-dispatch style used by most other languages.
Haskell and common lisp are at nearly opposite ends of the spectrum on many design decisions (Haskell is a Lazy, curried, typed language with lots of syntax and custom infix operators; Common Lisp is a (usually) eager, mostly[1] untyped language with little syntax and only prefix operators)
1: I say mostly because CL does have type declarations, but it's not defined how (or even if) the declarations are enforced in the CL standard. SBCL is arguably a typed implementation of CL, but even then, the fact that you can't in any useful manner[2] describe a type that is "A list of items of type X" in CL puts it in strong contrast to Haskell's rich type system.
2: You can use a "satisfies" type, but satisfies type declarations are ignored at compile time, so even in SBCL they are largely just syntax-sugar for assertions.
- galaxyLogic 6y agoI think everybody agrees that immutable data-structures are preferable to mutable ones if it is possible to get by without mutation in practice. In Haskell it seems it is difficult to mutate data, whereas in Lisp not so. If immutability is good then it would seem it is best if you can enforce immutability at the language level. I'm just wondering whether mutability is a downside of Common Lisp?