Path: utzoo!utgpu!attcan!uunet!ncrlnk!ncrcae!ece-csc!mcnc!xanth!nic.MR.NET!hal!cwjcc!mailrus!tut.cis.ohio-state.edu!husc6!rutgers!orstcs!mist!budd From: budd@mist.cs.orst.edu (Tim Budd) Newsgroups: comp.lang.smalltalk Subject: Re: Message dispatch on argument class Message-ID: <7220@orstcs.CS.ORST.EDU> Date: 7 Nov 88 17:14:32 GMT References: Sender: usenet@orstcs.CS.ORST.EDU Reply-To: budd@mist.UUCP (Tim Budd) Organization: Oregon State University - CS - Corvallis, Oregon Lines: 21 There is a technique called double polymorphism that does exactly what you want. It is described in more detail in a paper by Dave Unger in the first OOPSLA conference. Basically, you turn the argument around, and encode the type of the receiver for the first message in the message selector for a second message. Let me use mixed type arithmetic for an example. Class Integer would have something like the following: + x ^ x addToInteger: self addToFloat: x ^ x + self asFloat A class like Float would, when it receives the message addToInteger, know that it must convert the argument into float before adding. Here are a couple methods in class Float. + x ^ x addToFloat: self addToInteger: x ^ x asFloat + x The primitive methods are now addToInteger in class Integer and addToFloat in class Float.