On Feb 26, 6:19 am, Konrad Hinsen <konrad.hin...@laposte.net> wrote:
> 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.
>

Well, you have to do something (type in value, or override equals) but
I can't hardwire the relationship between type and equality,
especially not as an identity compare. There is no general solution,
else equals() wouldn't be overridable. Polymorphic equality is an
important capability, e.g. so sets and maps with different
implementations can interoperate.

> > 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.
>

I know, just noting sub-dispatching is possible.

Rich

--~--~---------~--~----~------------~-------~--~----~
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