Re: ObjC in time-critical parts of the code
Re: ObjC in time-critical parts of the code
- Subject: Re: ObjC in time-critical parts of the code
- From: Michael Ash <email@hidden>
- Date: Tue, 20 Jan 2009 00:09:17 -0500
On Mon, Jan 19, 2009 at 2:49 AM, Ben Trumbull <email@hidden> wrote:
>> Well no, it doesn't. ObjC has functions, by virtue of being a superset
>> of C, but it does not have "member functions". You can write functions
>> that are logically associated with a class, but this is a human
>> construct, not one that the compiler knows about.
>
> Not sure what compiler you're using, but mine can tell the difference:
> #import <Foundation/Foundation.h>
> @interface Foo : NSObject {
> @private id a;
> }
> @end
> static id plainCFunction(Foo* f);
> static id memberCFunction(Foo* f);
> static id plainCFunction(Foo* f) {
> return f->a;
> }
> @implementation Foo
> static id memberCFunction(Foo* f) {
> return f->a;
> }
> @end
>
> /tmp/members/members.m: In function 'plainCFunction':
> /tmp/members/members.m:12: warning: instance variable 'a' is @private; this
> will be a hard error in the future
That's just a slight modification of access permissions due to the
placement of the function definition. It does not make it a "member",
which to me would mean some kind of namespacing, ownership, or at
least some kind of association with the class. Although the access
permissions are somewhat relaxed, the function is still not associated
with your class in any way.
A minor quibble, but I think it's important, as for example there's no
way to get any information about the function using the Objective-C
runtime, and there's no way to even find out whether the function is a
"member" or not besides diving into the .m file and seeing whether
it's inside or outside the @implementation block.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden