[578] in java-interest
Re: Operator overloading (was BigInteger)
daemon@ATHENA.MIT.EDU (Tom Wheeler)
Mon Jul 3 15:27:40 1995
Date: Mon, 03 Jul 95 10:33:15 EDT
From: tomw@intelligraphics.com (Tom Wheeler)
To: java-interest@java.Eng.Sun.COM
> 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
>
> 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.
I thought of what I _think_ is a solution to this problem some time ago,
but haven't tried to implement it. First, have operator + return an
object of type "tempString". Then, tempString::operator + modifies
_itself_ instead of creating a new string, as String does. So after
the first temporary (tempString) is created, the other +'s just append
to it. I think you could also do this by using a boolean flag in String
itself. Again, I never tried this, so I don't know how well it would
work. (Though now that I'm reminded of it, I'm tempted to give it a
shot.)
Regards,
Tom Wheeler
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com