Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!ucla-cs!zen!ucbvax!decvax!tektronix!tekcrl!patc From: patc@tekcrl.TEK.COM (Pat Caudill) Newsgroups: comp.lang.smalltalk Subject: Re: A question... Message-ID: <1856@tekcrl.TEK.COM> Date: Wed, 5-Aug-87 16:14:49 EDT Article-I.D.: tekcrl.1856 Posted: Wed Aug 5 16:14:49 1987 Date-Received: Sat, 8-Aug-87 07:37:36 EDT References: <4357@felix.UUCP> <1549@tekchips.TEK.COM> Reply-To: patc@tekcrl.UUCP (Pat Caudill) Organization: Tektronix, Inc., Beaverton, OR. Lines: 37 >In article <4357@felix.UUCP>, preston@felix.UUCP (Preston Bannister) writes: > > The class Point responds to '+'. The examples show both: > aPoint + aPoint i.e. (1 @ 2) + (3 @ 4) = (4 @ 6) > and > aPoint + aNumber i.e. (1 @ 2) + 3 = (4 @ 5) > What I don't see is how to write the method for '+' without explicitly > testing the class of the parameter. Something like: Besides using the method that Steve Vegdahl describes, I would like to suggest the method pointed out by Dan Ingalls in a paper at the OOPSLA-86 conference. I will use the convention, as he did, of showing the class of the receiver in <> before the message. + aValue ^aValue pointPlus: self Then define pointPlus in both number and point as pointPlus: aPoint ^ (self x + aPoint x) @ (self x + aPoint y) pointPlus: aPoint ^ (self + aPoint x) @ (self + aPoint y) The full reference is: Daniel H. H. Ingalls, "A Simple Technique for Handling Multiple Polymorphism" OOPSLA'86 Conference Proceedings (Sigplan Notices Vol 21 #1 (Nov 1986)) pp 347. I hope this helps. Pat Caudill patc@tekcrl.TEK.COM