Re: Generics vs. Message passing: object namespaces

Pascal Costanza <[email protected]> Sat, 24 Feb 2007 02:16:57 +0100
Newsgroups gmane.comp.lang.lightweight
Message-ID <[email protected]>
On 23 Feb 2007, at 19:11, Tom Locke wrote:

>> But it seems that it should be trivial to have, in a CLOS-style  
>> generic function system, 'draw' bound to a function that would  
>> look at the type of its first argument and dispatch to the  
>> appropriate GF. Then you'd have:
>>
>> (draw gun args)
>
> This is exactly what I've been wondering about. It's essentially a  
> hybrid of object-dispatch and GF. I have a feeling though, that the  
> CLOS proponents will object to the special status afforded to the  
> first arg.

In CLOS, the first argument has more precedence in determining method  
specificity than later arguments, so in this sense, CLOS already  
gives the first argument a special status. (This is also called  
asymmetric dispatch. In Dylan, dispatch is symmetric. The  
disadvantage of symmetric disptach is that it may signal errors when  
it cannot resolve method specificity.)

> Anyone see any problems with this?

I find it counter-intuitive to use the same function for vastly  
different purposes, no matter whether it is a generic one (in the  
CLOS sense) or not.

> T.
>
> p.s. I think Mike hit the nail on the head - it's about pragmatism  
> not absolutes. As you said yourself recently Pascal, language  
> design is all about convenience, and shorter, more readable names  
> are more convenient, even if there are occasions when you have to  
> fall back to a more verbose style.

Compared to the expresive power that generic functions buy me, I  
remain very unexcited about the naming issue.


Pascal

-- 
Pascal Costanza, mailto:[email protected], http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium