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

> In CL, I must do ugly things like provide equality predicates to functions, as opposed to having them associated to the data structure itself.

> Immutable/persistent data structures: Clojure has this pretty covered. It is possible to implement these data structures in other Lisps, like Common Lisp, but they're not bound to be very efficient.

You really should take a look at FSet[0]. Not only does it provide fairly efficient persistent implementations of functional datatypes -- not as fast as Clojure's, perhaps, but not bad -- but it allows you to associate your equality predicates with your datatypes rather than passing them to every operation explicitly. (In fact, FSet currently provides no way to pass the predicate explicitly. Some people, including Faré, think this is an unfortunate omission, but I've never needed to do that.)

[0] http://common-lisp.net/project/fset



I know about FSet and have used it in production. It indeed is a library that has an immutable data structure.

FSet's solution to the equality "issue" is by having a generic function COMPARE which will return :LESS, :GREATER, and whatnot.

FSet goes to length describing the issues embedding immutable data structures in an inherently mutable language. Things like RENAME-PACKAGE screw up invariants that FSet expects.

Lastly, FSet admits that it isn't exactly performant, it's just good enough, which was the point I was trying to make.

Aside from a few gripes I have, it's a good library to use, especially in multithreaded environments where you don't want to deal with locking and whatnot.


Glad to hear you like FSet! (Not sure if you noticed: I am the author.)

I protest, though, that there's nothing about Common Lisp that makes FSet slower than Clojure. Rich Hickey used a very clever data structure called a Hash Array-Mapped Trie to implement Clojure sets and maps, and (I think) an Okasaki-style sequence implementation. FSet, in contrast, uses balanced binary trees for all these types. That's the source of the performance difference, not anything about CL.

What are your gripes about FSet?




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

Search: