Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!psuvax1!burdvax!sdcrdcf!trwrb!felix!preston From: preston@felix.UUCP (Preston Bannister) Newsgroups: comp.lang.smalltalk Subject: A question... Message-ID: <4357@felix.UUCP> Date: Mon, 3-Aug-87 20:24:33 EDT Article-I.D.: felix.4357 Posted: Mon Aug 3 20:24:33 1987 Date-Received: Thu, 6-Aug-87 07:31:45 EDT Sender: daemon@felix.UUCP Reply-To: preston@felix.UUCP (Preston Bannister) Organization: FileNet Corp., Costa Mesa, CA Lines: 48 I have been writing a set of class definitions to support graphics in Little Smalltalk from the descriptions in the Smalltalk-80 books. 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: + delta (delta class == Point) ifTrue: [^ Point new x: (self x + (delta x)) y: (self y + (delta y)) ] ifFalse: [^ Point new x: (self x + delta) y: (self y + delta) ] (This may not be correct Smalltalk. I'm not that familiar with the language and the book is not in front of me.) Somehow I would have expected to write two methods: + aPoint ^ Point new x: (self x + (delta x)) y: (self y + (delta y)) + aNumber ^ Point new x: (self x + delta) y: (self y + delta) But this doesn't seem possible. Am I missing something?? ======================================== Preston L. Bannister USENET : ucbvax!trwrb!felix!preston BIX : plb CompuServe : 71350,3505 GEnie : p.bannister -- ======================================== Preston L. Bannister USENET : ucbvax!trwrb!felix!preston BIX : plb CompuServe : 71350,3505 GEnie : p.bannister