[1013] in java-interest

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

Re: overloading of operators

daemon@ATHENA.MIT.EDU (Tom Wheeler)
Wed Aug 16 19:56:08 1995

Date: Wed, 16 Aug 95 09:23:29 EDT
From: tomw@intelligraphics.com (Tom Wheeler)
Reply-To: tomw@intelligraphics.com (Tom Wheeler)
To: java-interest@java.Eng.Sun.COM

Well, this is rather interesting.  Proponents of overloading claim that it
leads to easier-to-read programs, and its detractors claim that it leads to
programs that are harder to read!

Proponents say that

  x + y * z

is easier to read than

  x.SomeFunc (y.AnotherFunc (z));

That seems reasonable to me.  Detractors argue that the latter is
more readable because you _know_ what SomeFunc() and AnotherFunc()
do - you don't have to guess at their meaning.  True, but only if
SomeFunc() and AnotherFunc() have names that make sense and if they
don't have surprising side effects.  Anybody who's ever had to read
someone else's code knows these aren't guarantees by any means.

So it seems to me that the main argument of the detractors also holds
true for regular, old-fashioned function names.  Operator overloading
is easier to abuse, true - but because operators have (typically)
well-defined meanings it should also be easier to adhere to those
meanings.


Regards,
Tom Wheeler
tomw@intelligraphics.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