comp.lang.ada
 help / color / mirror / Atom feed
From: rrw1000@cus.cam.ac.uk (Richard Watts)
Subject: Re: Why one school changed from Pascal to C++
Date: 1997/05/06
Date: 1997-05-06T00:00:00+00:00	[thread overview]
Message-ID: <5kn15j$6sa@lyra.csx.cam.ac.uk> (raw)
In-Reply-To: 8229B62E52EAC144.6C6C6DF4FB6915C3.A10EAF24E2BF24E1@library-proxy.airnews.net


In article <8229B62E52EAC144.6C6C6DF4FB6915C3.A10EAF24E2BF24E1@library-proxy.airnews.net>,
Kevin Cline <clines@delete_this.airmail.net> 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.




  parent reply	other threads:[~1997-05-06  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <33664F10.6B76@mathernet.com>
1997-05-02  0:00 ` Why one school changed from Pascal to C++ Philippe Allenbach
1997-05-02  0:00   ` Richard Watts
1997-05-03  0:00     ` Kevin Cline
1997-05-02  0:00       ` Farshad Nayeri
1997-05-05  0:00         ` Rennie Allen
1997-05-05  0:00           ` Farshad Nayeri
1997-05-06  0:00       ` Richard Watts [this message]
1997-05-06  0:00         ` Farshad Nayeri
1997-05-06  0:00         ` Robert Dewar
1997-05-06  0:00           ` Spencer Allain
1997-05-13  0:00             ` W. Wesley Groleau (Wes)
1997-05-15  0:00               ` Kaz Kylheku
1997-05-02  0:00   ` Lance Kibblewhite
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox