Re: Trickiness with protocols and extends (1.3.0)

2011-10-31 Thread Howard Lewis Ship
On Sat, Oct 29, 2011 at 7:02 AM, David McNeil wrote: > A couple of more thoughts on this. > > On Oct 28, 12:46 pm, Howard Lewis Ship wrote: >> (extend-type cascade.Asset >>   ToAttributeValueString >>   (to-attribute-value-string [asset] (:client-url asset))) > > The reason this is probably not w

Re: Trickiness with protocols and extends (1.3.0)

2011-10-29 Thread David McNeil
A couple of more thoughts on this. On Oct 28, 12:46 pm, Howard Lewis Ship wrote: > (extend-type cascade.Asset >   ToAttributeValueString >   (to-attribute-value-string [asset] (:client-url asset))) The reason this is probably not what you really want is that the set of types which satisfy the As

Re: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread David McNeil
On Oct 28, 12:46 pm, Howard Lewis Ship wrote: > (extend-type Asset >   ToAttributeValueString >   (to-attribute-value-string [asset] (:client-url asset))) As Alex mentioned we have an "adapt-protocol" macro [1] [2] that I think will do what you want. It would be invoked as: (adapt-protocol Ass

Re: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Nicolas
Hi ! For clojure, a type or a record, represent data. A protocol represent a set of linked polymorph functions. But protocol themselves are not types. Just grouped functions. The types is what they apply on. Not what they are themselves. You can view each method of a protocol like a big swich fun

Re: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Alex Miller
Howard, I didn't read all of your post because frankly, I'm lazy, but David is correct that you will run into difficulties with hot protocol on protocol action. However, I personally think there are excellent reasons for wanting to extend protocols on protocols and fellow Revelytix-ian David McNei

Re: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread David Powell
On Fri, Oct 28, 2011 at 6:46 PM, Howard Lewis Ship wrote: >From my perspective, defprotocol appears to create a name (in the > current namespace) as well as a Java interface (the real type). It > feels to me like I should be able to pass either the interface or the > protocol into extend-type and

Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Howard Lewis Ship
I'm hitting a bit of frustration with (defprotocol) and friends and I'm hoping someone can enlighten me: Context: this is part of the Cascade layer I'm building on top of Compojure. It's all about rendering markup, borrowing ideas from Tapestry. I have a protocol that represents Assets: any kind