From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,1bc17347df0c2d32 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,1bc17347df0c2d32 X-Google-Attributes: gid103376,public X-Google-Thread: 1008e3,1bc17347df0c2d32 X-Google-Attributes: gid1008e3,public From: rrw1000@cus.cam.ac.uk (Richard Watts) Subject: Re: Why one school changed from Pascal to C++ Date: 1997/05/06 Message-ID: <5kn15j$6sa@lyra.csx.cam.ac.uk>#1/1 X-Deja-AN: 239702620 References: <33664F10.6B76@mathernet.com> <5kd7eo$2b4@lyra.csx.cam.ac.uk> <8229B62E52EAC144.6C6C6DF4FB6915C3.A10EAF24E2BF24E1@library-proxy.airnews.net> Organization: University of Cambridge, England Newsgroups: comp.lang.ada,comp.lang.eiffel,comp.lang.modula3 Date: 1997-05-06T00:00:00+00:00 List-Id: In article <8229B62E52EAC144.6C6C6DF4FB6915C3.A10EAF24E2BF24E1@library-proxy.airnews.net>, Kevin Cline wrote: > >rrw1000@cus.cam.ac.uk (Richard Watts) wrote: > >> It's interesting that they seem to rate things like initialisation >>and overloading as plusses for ADT implementation: experience seems to >>indicate that full transparency is often a bad idea (do you _really_ >>want to give the impression that matrix multiplication is >>commutative ?). > >Why should the use of '*' imply commutativity? Surely almost all programmers >working on code that does multiply matrices will know that matrix >multiplication is not commutative. If they don't, that is a training problem, >not an argument against operator overloading. Well, yes and no. There's a limit to how many special cases one can hold in memory at once - * usually denotes multiplication. What you do to matrices is not by any stretch of the imagination multiplication, so why should it have the same name ? It's bad enough having it represent both integer and (three kinds of) fp multiplication, but that doesn't usually matter since their only differences come out in special cases one doesn't usually (expect to) encounter. > It's no more obvious that >the order of arguments to matrix_multiply is important. I'd say that it was: you usually expect the order of arguments to a function to be important, it's just that for * you're told by the language definition that they usually aren't. My experience has been that situations where behaviour is described not by the operation but by the type of the operands tend to be (very) confusing. I can't think of many operators which it makes sense to overload without changing their behaviour significantly - bignums might be one such situation, but even then if you're mixing integer * and bignum * you have to be careful that you don't run into recursive loops (trying to allocate memory by doing calculations which allocate memory and the like). > >Symbols are used in mathematics because they are easier to read than text. >They are used in computer programs for the same reason. Yup, and they're confusing in mathematics too - I don't know about you, but I spend a lot of my time being confused when maths books start calling the operation in a non-abelian group `multiplication' (and then go on to use real multiplication and the group operation together ...). Richard. -- SAY AGAIN STOP IS USENET DEAD OR DECEASED STOP The University of Cambridge can't have these opinions even if it wants them.