git » homepage.git » master » tree

[master] / archive / forums / hacker-news / raw / items / 18842694.json

{"by":"wooby","id":18842694,"kids":[18843888,18843232,18844415],"parent":18842024,"text":"Strictly speaking: yes. But whether conses (aka pairs), lists, or other derivative structures support pervasive FP in a language is probably most influenced by whether conses are mutable or not.<p>In Common Lisp, they are. In Scheme, they are not.<p>Mutable conses are useful because at least because values can be accumulated in a list from the end by retaining and mutating the tail.<p>However, the presence of mutable conses detracts from a language&#x27;s ability to support FP, since it must be done by convention and with much copying.<p>I see Clojure&#x27;s innovation in this area not in the fact that its lists are immutable (Scheme did this already) but in the fact that its lists are immutable <i>and</i> there&#x27;s never a need to mutate the tail, because lazy sequences are supported throughout the language. The icing on the top of the story is that concrete lists and lazy sequences both inhabit the &quot;Seq abstraction&quot;, and so don&#x27;t require different APIs most of the time.<p>Of course, I&#x27;m pretty sure lazy sequences existed before CL was standardized (they&#x27;re in SICP), but I can imagine how the designers would have preferred a simple, well-known tool (mutable conses) over admitting a whole other sequence abstraction. Plus, immutable conses would have been a breaking change.<p>So, it&#x27;s not that anything that Clojure does with regard to lists couldn&#x27;t have been done before, just that it wasn&#x27;t -- while also being packaged in a vehicle that was wildly compelling for many other unrelated reasons.","time":1546833865,"type":"comment"}