Re: Generics vs. Message passing: object namespaces
[email protected] Fri, 23 Feb 2007 13:28:31 -0500 (EST)
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
> On 2/23/07, [email protected] <[email protected]> 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? No, I think that is correct, but that is not how CLOS-style generic OOP works, the original subject of criticism. You could in fact say that that is just syntactic sugar on the syntax "object.method(args)", rewritten "(method object args)". But it also brings up additional design issues like, how do you decide which symbols refer to methods and thus when to look at the arguments before looking at the signature of the function-position symbol (which you presumably looked at before looking at the arguments)? I don't think this is necessarily an unsolvable problem, but it must be solved to proceed. The deal with object dispatch is that what argument provides the namespace for dispatch is explicitly marked with special syntax in the call. This inhomogeneity may seem inelegant to LISPers but it does have the great advantage of simplicity in dispatching method calls, in that one immediately leaves the global namespace and arrives in a much narrower one contextually relevant to the call.