4 ms·
A question: How does CLOS rate in terms of "functional purity". Or does it matter? The biggest selling point of Haskellers seems to be that Haskell is a "pure"
by galaxyLogic 6y ago
A question: How does CLOS rate in terms of "functional purity". Or does it matter? The biggest selling point of Haskellers seems to be that Haskell is a "pure" functional language. Are there practical problems caused by mutable data in CLOS?
- reikonomusha 6y agoCLOS doesn’t require the use of mutation and in fact has explicit options to make data read-only. So it’s a matter of personal discipline whether you mutate or not, though I’d say it’s entirely idiomatic to mutate.
- aidenn0 6y agoI'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?
- vindarel 6y agoThere was a recent article with snippets in Haskell and Lisp: http://www.lispology.com/show?3FY9 http://www.lispology.com/show?3FY9 "Haskell-like patterns in Lisp"
- galaxyLogic 6y agoEnlightening, thanks
- chalst 6y agoCLOS is about generics, so is about the type system, and is in practice pretty much orthogonal to purity. CLOS was originally implemented using macros, which are semantically pure. CLisp supports but, unlike Scheme, does not really encourage programming based on functional purity. Only the CLisp implementations that support full tail recursion are OK choices for pure functional programming.
- lispm 6y ago> CLOS was originally implemented using macros it was also implemented originally with variables, functions, types, system specific data types, numbers, symbols and a bunch of other things, including itself. > CLisp supports but Note that CLISP is an implementation of Common Lisp. The language itself is abbreviated as CL, not CLISP. If one says CLISP, then one only means CLISP, the specific implementation. The name CLISP comes from the implementation being implemented using C.
- deleted 6y ago[deleted]