Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)
Walter Bright
newshound1 at digitalmars.com
Wed Apr 15 17:59:44 PDT 2009
Don wrote:
> 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!
>
Adding in < and > for templates just makes it all worth while!
More information about the Digitalmars-d
mailing list