Re: Generics vs. Message passing: object namespaces
"Matt Knox" <[email protected]> Fri, 23 Feb 2007 14:22:04 -0500
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
On 2/23/07, Jeremy H. Brown <[email protected]> wrote: > > "Matt Knox" <[email protected]> writes: > > 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? > > Multiple inheritance. I could have a gun-widget class which inherits > from both gun and picture. In your scheme, when I say (draw widget > args), which version of draw should execute? If there's any risk of > this sort of subclassing, you want to write (picture:draw widget args) > or (gun:draw widget args) explicitly. > > (Fans of the model-view-controller design pattern will look down on > this specific use of MI, of course.) > > Jeremy > If your OO system has a full linearization, (like Dylan and unlike CLOS, I think), then you have an unambiguous criterion, wouldn't you? -- (def (eval e l d c) (if (atom? e) ((ahandler (type e)) e l d c) (eval (car e) l d (fun (x) (evapp x (cdr e) l d c)))))