Re: Generics vs. Message passing: object namespaces
Pascal Costanza <[email protected]> Sat, 24 Feb 2007 02:09:47 +0100
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
On 23 Feb 2007, at 18:56, Matt Knox wrote: > If I understand it correctly, your point is that if you need the > draw method from gun, picture, blood, and duel modules, that in an > object-dispatch system, you can say: > > gun.draw args > duel.draw args > ...etc. > > instead of > (draw_gun gun args) > > 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) > ... > and the only differences would be syntax and the ease with which > autocompletion could be done. > > Am I missing something? It could be that the signatures of the two methods are incompatible (for example, one has less required arguments than the other). Then you cannot simply add them to the same generic function. (This is similar to the example of not being able to implement incompatible interfaces in the same class in Java.) Maybe it's possible to design a generic function approach in which this issue doesn't occur, but I wouldn't know how. Pascal -- Pascal Costanza, mailto:[email protected], http://p-cos.net Vrije Universiteit Brussel, Programming Technology Lab Pleinlaan 2, B-1050 Brussel, Belgium