Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking at generic



At 11:54 am -0700 30/10/04, email@hidden wrote:
And I also LOVE C++ operators even if don't use them too much, because I
LOVE to write:

    obja = objb;

I don't see how the above could be confusing to anyone.

It *looks* very simple and easy to understand, true, but what does it actually *mean*?


If this was Java I would know *precisely* and *unambiguously* what it means; it copies whatever value the pointer variable objb has to the variable obja. In C++ it could mean *absolutely anything*.

For all I know, obja could represent a database, objb could be a random object that has a toString method, and the designer of the database class thought it would be really "clever" that if you assigned a string to the database then clearly what you want to do is execute some SQL. And maybe it's just a typo in my code, I really meant to assign to obja1 which has the same type as objb, not talk to the database at all, but the compiler helpfully applied a cast for me.

Granted, it probably won't, or if it does the names of the classes or the API documentation (if there is any) might make it clear what they're intended for, but it could. Short of guessing, or knowing because I wrote the code, or trailing through hundreds of header files, I have absolutely no way of knowing for certain what this apparently simple statement does.

Operator overloading is absolutely, completely and utterly evil, sorry.

-Rolf
--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.