On Feb 26, 2009, at 1:51, Rich Hickey wrote:

> You raise interesting issues and I'd like to explore them further. I'm
> not sure the issues you have with type-tag-or-class dispatch are all
> that prohibitive. In any case, I've added a type function that returns
> the :type metadata or the class if none:
>
> user=> (type #^{:type ::Fred} [1 2 3])
> :user/Fred
>
> user=> (type "foo")
> java.lang.String
>
> which should help people standardize.

One inconvenience I noticed with types based on meta-data tags is  
that the type information does not participate in equality tests.  
This means I have to include the type information once again in the  
value itself if I want to make sure that no other type's value  
accidentally compare as identical to mine.

> If you want to multiplex multimethods for your ADT type, you can just
> define a single :type ::ADT, and then sub-dispatch on e.g. :adt-type.

That's not even necessary: I add a derive clause from ::adt to each  
of my data types and implement multimethods such as print-method  
for ::adt.

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