Re: self = [super init], nil?
Re: self = [super init], nil?
- Subject: Re: self = [super init], nil?
- From: Kyle Sluder <email@hidden>
- Date: Sat, 8 May 2010 08:12:46 -0700
On May 8, 2010, at 7:12 AM, gandreas <email@hidden> wrote:
A subtle but important point is that after init's self=[super init]
is the only time you normally could have self being NULL (the only
other time I can think of is when you do some form of IMP caching
and explicitly call the method with nil as the first parameter, but
this is pretty rare). So this means it is the only place where
accessing an ivar directly can cause a null dereference (unlike C++
where this can be null in any case where static typing allows
bypassing vtable dispatching, requiring extra care and paranoia).
For speed or correctness, we do TONS of pointer-identity dictionary or
other data structure stuff. Not much IMP caching, but often methods
will call C functions that take a "self" argument (so that they can
call themselves recursively without going through method dispatch each
time).
Now that we have blocks, I expect we'll be using a lot less of this,
but with our current codebase it pays to be safe.
--Kyle Sluder
_______________________________________________
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