Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ames!lll-tis!ptsfa!ihnp4!inuxc!iuvax!pur-ee!uiucdcs!uxc.cso.uiuc.edu!scaletti From: scaletti@uxc.cso.uiuc.edu Newsgroups: comp.lang.smalltalk Subject: Re: addition Message-ID: <178400003@uxc.cso.uiuc.edu> Date: Thu, 27-Aug-87 19:49:00 EDT Article-I.D.: uxc.178400003 Posted: Thu Aug 27 19:49:00 1987 Date-Received: Sun, 30-Aug-87 00:48:17 EDT References: <245100011@orstcs> Lines: 20 Nf-ID: #R:orstcs:245100011:uxc.cso.uiuc.edu:178400003:000:911 Nf-From: uxc.cso.uiuc.edu!scaletti Aug 27 18:49:00 1987 I needed double dispatching for implementing matrix arithmetic. While it is easy to use the coercion facility for standard numeric values, matrix arithmetic has two kinds of multiplication and an unusual addition. That is, you can have either scalar or matrix multiplication, which could possibly be taken care of with coercion (coerce a scalar to a properly scaled identity matrix of the right size, assuming you know which side of the matrix the scalar is going to multiply). Also, addition is only allowed between matrices of the same size. There would be no error checking, unless additional checks are placed in the retry:coercing: methods. In addition, double dispatching is much faster than the retry:coercing: mechanism, the resulting code is much cleaner (no class checks), and the code can also be verified to be type safe. The only drawback is the order n^2 number of methods. Kurt Hebel