[529] in java-interest

home help back first fref pref prev next nref lref last post

Re: Operator overloading (was: BigInteger class out there?)

daemon@ATHENA.MIT.EDU (Jake Kesinger)
Wed Jun 28 14:34:44 1995

Date: Wed, 28 Jun 1995 10:55:08 -0700 (PDT)
From: Jake Kesinger <jake@blegga.freerange.com>
To: Michael Lorton <mlorton@eshop.com>
Cc: java-interest@java.sun.com
In-Reply-To: <199506281529.IAA09500@eshop.com>


On Wed, 28 Jun 1995, Michael Lorton wrote:

> 
>    [Greg Wilkins <gregw@ind.tansu.com.au> writes]
> 
>    then you really need
>    a degree in pure maths to work out the group theory for any non-trival
>    classes that you want to use these features for.
> 
>    If it looks like * it needs to act like *, so the group of all your 
>    classes instances needs to be reflexive, transitive, have a unity 
>    instance etc. etc.
> 
> I disagree here also.  If I were writing a Matrix class, I would very
> much like to overload the *.  I would certainly NOT want reflexivity,
> since bA != Ab.  Moreover, the same argument could apply against
> methods with operator-like names (multiply() or add()).

Two things:
  1.  Are arithmetical expressions transitive in any programming language?
      I seem to remember hearing once that some compilers reserve the
      right to re-arrange lines in optimization.
  2.  No object in Java (to my knowledge) is a group under ``*''.
      ``*'' certainly isn't invertible (a*0==0), nor is it closed
      (MAXINT * 3).  Also, is it always true with IEEE floating point
      numbers that 1.0*f == f == f*1.0?


Has anyone considered operator methods?  i.e. something like 

public Complex operator (Complex b)Mult(Complex a);

Which would look like:
Complex x,y,z;
z := x Complex.Mult() y;
or
z := x Mult() y;


  --Jake

> 
> Any tool can be misused.  The question is does the potential cost of
> abuse exceed (or even approach) the benefit of proper use.  In the
> case of automatic conversion, I agree with the growing consensus that
> says yes.  I am not convinced about operator overloading; group theory
> is not going to convince me.
> 
> M.
> 
> -
> Note to Sun employees: this is an EXTERNAL mailing list!
> Info: send 'help' to java-interest-request@java.sun.com
> 
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post