I would like to extend an pre-existing Java class so that it operates as
a function. Now something like this...

(extend-type Object
  clojure.lang.IFn
  (invoke [this] (str "Hello:" this)))

((Object.))
=> "Hello Object@fdafsd"

seems like a good idea, but fails because IFn is not a protocol.

All the Objects that I am interested in are produced by a factory, so
another possibility is to extend the factory and have it return proxy
objects to the real objects implementing both their interfaces and IFn;
or just use gen-class. However, as the API have about 60 interfaces this
is a lot of effort -- I'd probably have to auto-generate the code.

Is there another way?

Phil

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to