Re: protocols and interfaces

2012-02-10 Thread drewn
> There's also defrecord I considered using that, but I need to do something more with the constructor (e.g. convert the map into a Java array for internal use). Also, defrecords only takes positional arguments, which will be hard to use with tens of arguments. (An alternative is just to pass in

Re: protocols and interfaces

2012-02-10 Thread Cedric Greevey
On Fri, Feb 10, 2012 at 1:07 PM, Aaron Cohen wrote: > On Fri, Feb 10, 2012 at 3:13 AM, drewn wrote: >> I've just started learning protocols, deftype, etc.  The first thing I >> did was try to extend a Clojure type (maps) to operate as a >> specialized Java Swing interface (AttributeSet), forgetti

Re: protocols and interfaces

2012-02-10 Thread Aaron Cohen
On Fri, Feb 10, 2012 at 3:13 AM, drewn wrote: > I've just started learning protocols, deftype, etc.  The first thing I > did was try to extend a Clojure type (maps) to operate as a > specialized Java Swing interface (AttributeSet), forgetting that > interfaces are not protocols; i.e. > > (extend-t

Re: protocols and interfaces

2012-02-10 Thread drewn
> Nope, can't be done. Java interfaces can't do this. I'm glad I asked the question. Given that it can't be done, any suggestions for the best way of handling this interop scenario? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Re: protocols and interfaces

2012-02-10 Thread Stuart Sierra
Nope, can't be done. Java interfaces can't do this. Java 8 may have "Interface Injection" which will make this possible. -S -- 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

protocols and interfaces

2012-02-10 Thread drewn
I've just started learning protocols, deftype, etc. The first thing I did was try to extend a Clojure type (maps) to operate as a specialized Java Swing interface (AttributeSet), forgetting that interfaces are not protocols; i.e. (extend-type clojure.lang.PersistentArrayMap javax.swing.text.Att