On Mar 20, 2009, at 16:18, Rich Hickey wrote:

>> Providing a :default implementation for multimethods is a very common
>> and useful technique, but it is really useful only for multimethods
>> that dispatch on a single argument.
>
> I disagree about that. No dispatch value, composite or not, is still a
> valid concept.

True, for reasons other than a default in a type hierarchy.

>> But suppose you want to provide a default for one argument only?
>> Something like
>>
>>         (defmethod + [java.lang.Integer ::any] ...)
>>
>
> I think it is best to think about this differently than :default, it's
> more about a universal parent than about a missing dispatch value.

It could be seen from both points of view (universal parent in the  
hierarchy, or a partial match with a default), but I agree that the  
universal parent point of view makes more sense.

>> Would it be a good idea to provide the possiblity to add a universal
>> parent to hierarchies? Or would that create any problems? Is there
>> another solution for the situation I described?
>
> Yes, don't know, and no. I briefly looked at this but only got as far
> as to decide Object couldn't be the universal parent. I think you have
> to reserve a value that will never otherwise be used.

Object would indeed not work, the universal parent would have to be  
even above Object.

I just looked at the implementation of hierarchies and I have the  
impression that this should be rather simple to implement. I will try  
and see how it works out in practice.

Konrad.


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