On Nov 24, 4:55 am, Allen Rohner <aroh...@gmail.com> wrote:
> The first stumbling point I reached is that deftypes provide an
> automatic implementation for IPersistentMap, but not IFn. I attempted
> to write (instance key), which exploded, but (key instance) works just
> fine. My existing code uses (instance key) almost universally. Should
> I get used to this, or are there plans to provide a default IFn
> implementation?

I agree that it would be nice with an automatic IFn implementation if
you specify the interface. As an alternative, you could use

user> (deftype F[x] [clojure.lang.IPersistentMap clojure.lang.IFn]
         (.invoke [k] (k this)))
#'user/F
user> ((F 42) :x)
42
user>

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