This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Find more ObjC methods



On Friday, Oct 3, 2003, at 12:00 US/Pacific, Devang Patel wrote:



On Oct 3, 2003, at 2:57 AM, David Ayers wrote:


[self somePrivatMethod]; /* <- should not see the prototype and warn! */

Does this mean that using private methods, that are not included in @interface, is not a good idea? I think, compiler should figure out that it is part @implementation and not warn about it.

Well, Objective-C plays it fast and loose here (as in many other places). :-) On the one hand,
you're definitely encouraged to provide an @interface for your class in a header that other
translation units can pull in. But on the other, you do not _need_ to provide an @interface at
all! It may not be very polite, but if the @implementation contains the required ivars,
the compiler knows what to do.


Furthermore, methods in Objective-C are not 'private' (or 'protected') in the C++ sense;
all methods _are_ visible to the runtime. So, in the example above, the program definitely
_will_ call 'somePrivateMethod'. Also, since we happened to see the @implementation in this
case, we can actually determine which 'somePrivateMethod' this will be.


--Zem
--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]