On Tue, Jan 3, 2012 at 11:13 AM, Tassilo Horn <tass...@member.fsf.org>wrote:
> Hi all,
>
> I'm playing around with core.match and trying to extend it to some
> custom types in terms of extending the IMatchLookup protocol on those.
> But that's not quite what I need.  IMatchLookup only specifies how to
> access some value out of my custom types, and in the `match' clauses
> those values are compared by equality to the values specified there.
>
> In my patterns, I want to have a :+type key with a value that's
> basically an interface name given as a symbol.  The pattern should
> match, if the class of the object implements that interface (or an
> extended interface thereof) directly or indirectly.  So that would be my
> ideal user interface:
>
> --8<---------------cut here---------------start------------->8---
> (match [obj]
>  [{:+type 'Cat :mice 4}]   :1
>  [{:+type 'Dog :cats 3}]   :2
>  [{:+type 'Mammal}]        :3
>  :else                     :nope)
> --8<---------------cut here---------------end--------------->8---
>

This is a known missing feature and there's a couple of open questions as
far as how to best implement this. It should probably support Java classes,
Java interfaces, types, records, protocols and high performance hinted
access to fields.

This is not the highest thing on my priority list, but I'm more than happy
to help if somebody wants to move forward with this sooner rather then
later.

David

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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