Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful
Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful
- Subject: Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful
- From: "Hamish Allan" <email@hidden>
- Date: Fri, 8 Feb 2008 17:35:16 +0000
On Feb 8, 2008 4:23 AM, John Engelhart <email@hidden> wrote:
> 'id' is the codified
> definition of an object in fact
Here we go again.
Perhaps your confusion between "an address in memory" and "the
contents of memory from that address" is at the heart of the problem?
The following code "proves" that objects and character arrays are "equivalent":
#import <Foundation/Foundation.h>
int main(int argc, char **argv) {
char string[] = "test";
id x = [NSObject class];
memcpy(string, &x, 4);
NSLog(@"object: %@", string);
}
$ gcc -framework Foundation -o test test.m
$ ./test
2008-02-08 17:33:21.514 test[1380:10b] object: <NSObject: 0xbffffa8b>
$
To put it a different way: memory is memory is memory. Data types give
us structured access to that memory. Objective-C objects are not
__strong, but ids (a special type of pointer to those objects) are
__strong. It's that simple. Take it or leave it, but don't run around
shouting that the sky is falling.
> Since
> __strong is not being treated as a type qualifier per ANSI-C rules,
> there is nothing in place to catch inadvertent "down promotions" when
> they happen.
You want to have the compiler warn you whenever you create a weak
reference. Fine: file an enhancement request. The sky still isn't
falling!
Hamish
_______________________________________________
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