[571] in java-interest

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

Re: Operator overloading (was BigInteger)

daemon@ATHENA.MIT.EDU (Patrick Doane)
Sat Jul 1 20:35:21 1995

Date: Sat, 1 Jul 1995 17:21:01 -0400
To: java-interest@java.Eng.Sun.COM
From: pdoane@pcnet.com (Patrick Doane)

>I assume you are referring to the commutative property, e.g. a + b == b + a.
>This is a _mathematical_ property, and people simply assume that it holds
>in programming as well.  This assumption must be dealt with by making it
>very clear that just because a mathematical operator is used in a language
>the operation may not follow mathematical convention - and in fact the
>behavior of the operator may not follow mathematical convention, as of
>course is the case with Strings.
>

 The problem I have with the operator overloading of the + operator is that
there is no way for (at least from experience), to have:

s1 = s2 + s3 + s4 + s5

translate to:

s1.assign(s2)
s1.append(s3)
s1.append(s4)
s1.append(s5)

 It usually constructs too many temporary objects in the mean time to be a
tool I would want to use. I'm glad that Java has built string operations
into the language so that they can be used as expected.


-
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