Re: (Newbie) Prototypes don't seem to compile?
Re: (Newbie) Prototypes don't seem to compile?
- Subject: Re: (Newbie) Prototypes don't seem to compile?
- From: "Louis C. Sacha" <email@hidden>
- Date: Thu, 26 Feb 2004 18:43:34 -0800
Hello...
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/3objc_language_overview/chapter_3_section_7.html#//apple_ref/doc/uid/20001424-114567
"The compiler creates a Protocol object for each protocol declaration
it encounters, but only if the protocol is also:
* Adopted by a class, or
* Referred to somewhere in source code (using @protocol()).
Protocols that are declared but not used (except for type checking as
described below) aren't represented by Protocol objects at runtime."
Louis
thank you for your reply, I might not have stated my question very
well. I understand the function of a protocol and how the @protocol
keyword is used, but I was surprised that the compiler doesn't at
least check the syntax of the protocol.. If I make a syntax mistake
the compiler ignores it, unless of course the protocol is
referenced by an implementing class.
You have an point that the @protocol contains no code, and by
Apple's documentation, is not a class. This is a good reason that
the protocol isn't compiled, but I find it very odd that the syntax
of a declared protocol is not checked by the compiler unless the
protocol has been implemented, and thus referenced, by a class.
I am writing some libraries that are quite heavy on the abstract
side of things, and who's purpose is to define what in Java would
be "Interface" classes.. I am implementing these with Objective-C
using @protocol, but since the library's purpose is just to define
the protocols not implement them I've found that the compiler
doesn't check my syntax at all, but rather just ignores the
protocols.
Any other insights into this?
Thank you for the reply,
Jason
Taking a look at the ObjC documentation that Apple provides might
help if you haven't read it already:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
3objc_language_overview/chapter_3_section_7.html#//apple_ref/doc/uid/
20001424/BAJJABHJ
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.