Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)

Don nospam at nospam.com
Wed Apr 15 00:14:11 PDT 2009


Walter Bright wrote:
> My problem with operator overloading stemmed from C++'s endorsement of 
> using >> and << for stream operations.

I saw someone who wrote a database library, and used << and >> for 
stream operations. Then he needed a second form of stream operations, so 
he overloaded > and <.

db < x < y; // stores x and y in the database
(db < x) < 7; // stores x and 7 in the database
db < (x < 7); // stores a bool in the database.
if (db > x) { zzz; } // gets x from the database, then does zzz.

What fun!




More information about the Digitalmars-d mailing list