Re: Trait-like behavior with Protocols

2010-02-09 Thread Jeff Rose
I think the extend function is made exactly to support the concrete implementation of protocols. It takes a type, and then any number of protocol + function map pairs, where keyword names map to functions. Checkout the protocol docs on assembla and look for extend:

Re: Trait-like behavior with Protocols

2010-02-09 Thread Konrad Hinsen
On 09.02.2010, at 02:14, Stuart Sierra wrote: On Feb 8, 6:13 pm, aria42 ari...@gmail.com wrote: (defprotocol Span (start [self]) (stop [self]) (span-length [self])) Now I know I can just make span-length a function on Span as opposed to part of the protocol. Is that what one should

Re: Trait-like behavior with Protocols

2010-02-09 Thread aria42
If this situation is common enough, shouldn't defprotocol support optional implementations which are implicitly merged? On Feb 9, 6:01 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 09.02.2010, at 02:14, Stuart Sierra wrote: On Feb 8, 6:13 pm, aria42 ari...@gmail.com wrote:

Re: Trait-like behavior with Protocols

2010-02-09 Thread Konrad Hinsen
On 9 Feb 2010, at 22:29, aria42 wrote: If this situation is common enough, shouldn't defprotocol support optional implementations which are implicitly merged? Yes, if it is common enough. It's perhaps too early to decide. Konrad. -- You received this message because you are subscribed to

Trait-like behavior with Protocols

2010-02-08 Thread aria42
Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span (start [self]) (stop [self]) (span-length [self])) Now I know I can just make span-length

Re: Trait-like behavior with Protocols

2010-02-08 Thread Stuart Sierra
On Feb 8, 6:13 pm, aria42 ari...@gmail.com wrote: (defprotocol Span   (start [self])   (stop [self])   (span-length [self])) Now I know I can just make span-length a function on Span as opposed to part of the protocol. Is that what one should do? Yes. -SS -- You received this message

Re: Trait-like behavior with Protocols

2010-02-08 Thread Dan Larkin
On Feb 8, 2010, at 6:13 PM, aria42 wrote: Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span (start [self]) (stop [self]) (span-length

Re: Trait-like behavior with Protocols

2010-02-08 Thread Meikel Brandmeyer
Hi, On Feb 9, 12:13 am, aria42 ari...@gmail.com wrote: Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span   (start [self])   (stop [self])