Path: utzoo!attcan!uunet!dino!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.object Subject: Re: Inheritance explained... finaly... Message-ID: <135300021@p.cs.uiuc.edu> Date: 12 Jan 90 17:32:08 GMT References: <1130005@gore.com> Lines: 35 Nf-ID: #R:gore.com:1130005:p.cs.uiuc.edu:135300021:000:1822 Nf-From: p.cs.uiuc.edu!johnson Jan 11 10:40:00 1990 >jgl@lambda.UUCP (J. Giles) writes >Yes, double dispatching will work for commutative operators. This >is an inefficient and clumsy solution which happens to work (and leave >_some_ people satisfied). However, a lot of operators aren't commutative. >As I originally said: the asymetrical nature of message passing is >quite appropriate for some data types but not for others. It's >unfortunate to be forced to choose instead of being given a language >which allows a choice between the two mechanisms. I agree that the asymetrical nature of message passing is not appropriate for all data types, but I disagree with everything else. Double dispatching is actually quite efficient. In my opinion, it is also quite elegant. Moreover, it works best with noncommunitive operators. Double dispatching is a good way to implement those data types that require symetrical method lookup. The major problem with double dispatching in Smalltalk is that the programming environment does not support it. Kurt Hebel and I have a paper in an upcoming issue of JOOP that describes a double dispatching browser that makes it very easy to write code that uses double dispatching. It automatically writes all the little methods for message forwarding, automates inheritance along the lines of the class of the second object, and in general makes the implementation of the arithmetic classes in Smalltalk very symetrical. Kurt completely reimplemented the Smalltalk arithmetic classes, adding matrices, vectors, functions, etc. I like double dispatching because my Smalltalk compiler can produce very efficient code for arithmetic that is implemented using it, but Kurt is very happy with it in Smalltalk-80. The resulting system is very similar to CLOS generic functions from the programmer's point of view. Ralph Johnson