Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not a Clojure developer but, IIRC, Clojure doesn't have conses, but rather the function cons creates a seq. A Seq in Clojure is immutable and (usually) lazy, which is nothing like what CONS makes in lisp (a mutable pair that is the basis for building singly-linked lists).

Note that linked-lists are only a good data structure in fairly narrow contexts (e.g. shared structure, certain types of mutation you can do). Since Clojure is focused on limiting mutation, it makes sense for them to use Seqs instead of linked-lists.



Didn't racket also make the decision to make cons create immutable lists (and using mcons for mutable lists)?


But that's not what Clojure did. In clojure, cons cells aren't cons cells: they're a cell that can point to a sequence of some type, and contain a pointer to arbitrary data. They also do not make up lists, and have weird equality rules.

Racket's conses are merely immutable.


However, conses can be used for other types of structures as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: