Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!orstcs!mist!budd From: budd@mist.CS.ORST.EDU (Tim Budd) Newsgroups: comp.lang.c++ Subject: Re: Arguments to Overloaded Operators Message-ID: <11069@orstcs.CS.ORST.EDU> Date: 9 Jun 89 21:59:53 GMT References: <11032@orstcs.CS.ORST.EDU> <6590145@hplsla.HP.COM> Sender: usenet@orstcs.CS.ORST.EDU Reply-To: budd@mist.CS.ORST.EDU (Tim Budd) Organization: Oregon State Univ. -- Computer Science Lines: 21 The technique used by Jim Adcock in his response to my original question about the inconsistent handing of left and right arguments in overloaded opertors is what is known as multiple (or double) polymorphism. It was introduced by Dan Ingalls in a paper in the first OOPSLA conference, and deserves to be more widely known and used. (Actually, Adcock's idea is a very slight improvement on Ingalls - rather than encode the type of the receiver in the selector for the reverse message, i.e., addToInteger, addToFloat, etc, he encodes it as the overloaded type, i.e. addTo(Integer& x) addTo(Float& x). In practice I don't think this makes any difference). I was aware of this technique; the point of my note (well hidden) was to point out that you needed some trick like this, and that overloaded operators didn't solve the complete problem. Anyway, to get to the point; I've written a technical report describing two different generalized arithmetic packages in C++, comparing the efficiency of Smalltalk style coercive generality to double polymorphism. This should be back from the printers in a week or so. If you would like a copy send me a paper mail address. (Actually, if you can read LaTex I can e-mail the raw document). --tim budd, budd@cs.orst.edu