4 ms·
Common Lisp currently isn’t so great for purely functional programming. The language has the equivalent of GOTO, imperative loops, mutable objects, etc. But wor
by reikonomusha 8y ago
Common Lisp currently isn’t so great for purely functional programming. The language has the equivalent of GOTO, imperative loops, mutable objects, etc. But work is being done to make it a better functional language.
- dreamcompiler 8y agoYou can write purely functional programs in CL by simply choosing not to use those constructs. Most modern Common Lisps have proper tail call elimination, so you don't need loops. I can think of a couple of issues with Common Lisp that make it less ideal for FP than Haskell, but they don't involve the things you mentioned.
- coldtea 8y agoLisp was never meant not to have those. The idea that "functional programming == immutability" is a modern one, not the traditional understanding of functional programming. In fact, 10-something years ago, nobody really cared much on immutability on HN, while everybody still talked about Lisp and functional programming (it was all about first class functions, closures, map/reduce, recursion, DSLs, and macros). Immutability come into the fore (well, for HN) along with Haskel and Clojure -- plus the idea that immutability gives you multicore for free. Even in Paul Graham's essays, the "foundational documents" of this community, when he talks about Lisp he hardly talks about immutability as any kind of key point.
- macintux 8y agoThere are all sorts of ways that immutability helps at scale, so it's not surprising that as time goes by it seems more and more useful.
- fulafel 8y agoThe meaning of functional programming has shifted over time. First class functions, currying, anonymous functions etc have come to mainstream languages and modern fp has developed immutable data, lenses, etc.
- sedachv 8y ago> The language has the equivalent of GOTO Common Lisp does not have the "equivalent of GOTO," it has GOTO. I don't know why you think that is a bad thing.
- kazinator 8y ago"equivalent of goto" is meaningless; there is no one single conception of goto. The ultimate goto is a jump instruction in the machine language. Even these are not all the same; some have more constraints than others. Machine language goto will typically go from one function into another; the C goto will not. CL's go operator is a mechanism for abandoning the currently executing form up to just below an enclosing tagbody or prog, subsesquent to which, another subform of that tagbody/prog is selected for evaluation, identified by the label that was specified the go form. The initial abandonment of the original form a non-local dynamic control transfer, with all the unwinding that implies. Then the final transfer to another form resembles an unconditional branch. CL go will jump between function activations. A tagbody that has not itself terminated yet can be re-entered by means of a lexical closure. A jump out of that closure is possible.