On Apr 23, 2009, at 18:59, Mark Engelberg wrote:

> Konrad has written a library that turns equality into a multimethod.
> This provides the hooks for altering equality for maps, but there are
> a lot of questions in my mind about how well this will coexist with
> other Clojure code and just how severe the performance impact will be.

I can't say much about performance yet. As for coexistence, there are  
two issues:

1) Any code working with your map-based types will have to use the  
generalized equality rather than the built-in equality test. Whether  
or not this is a problem depends very much on the nature of your data  
and the code working on it. The more you want to plug your data into  
completely unrelated functions, the more problems you can expect.

2) Sets and maps use internal equality tests, which you can't change.  
That means you can't really use your data types as elements of sets  
or keys in maps.

I found that for many data types this is not a real issue, since I  
was able to find a representation for which the built-in equality is  
just fine. In your fraction example, it would be sufficient to ensure  
normalization after every arithmetic operation and in the constructor  
function defined as part of the API.

Konrad.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to