Design Element
Comment on "CocoaHeads: Objective-C 2.0"
by Nicko — Sep 22
If you consider 64-bit versus 32-bit, and whether the variable is a pointer or a simple value type, plus can already mean a number of things. Adding "whatever the programming thinks plus means" is an additional burden.

You are right that C's implicit casting of numerical types can be confusing, and that there is already a meaning for adding integer types to pointers. That said part of the issue here is a mind-set in which object handles are being thought of as structure pointers rather than opaque references. The ObjC syntax certainly allows one to use the form (objHandle + 42)->member, but I can't say that I've ever seen that used. As such (since we're talking about a fundamental language change) I'd rather see that form deprecated for use with Object pointers and attempts to use it will just cause the compiler to warn objClass may not respond to '__add__:' or something of that ilk.

In the end I think this debate ultimately comes down to the question "Do I trust the authors of code I have to read to use overloaded operators in a manner that is intuitive and meaningful?" If I don't trust them to do this then overloaded operators will mean I have to look all over the place to find the meaning of their code. If I do trust them then I'll be able to skim through the code and know what the programmer meant much more quickly than if the code was all in line. Perhaps I just have more faith in other programmers than you do :-)
Back to "CocoaHeads: Objective-C 2.0"
Design Element

Copyright © Scott Stevenson 2004-2015