On May 29, 2015, at 1:42 PM, Quincey Morris wrote:

> On May 29, 2015, at 10:35 , Jean-Daniel Dupas <mail...@xenonium.com> wrote:
>> 
>> You must at least returns nil in the fast path, else the compiler will not 
>> be happy.
> 
> Shame on you, Jean-Daniel, for not spotting the other error!
> 
> On May 29, 2015, at 10:22 , Alex Zavatone <z...@mac.com> wrote:
>> 
>>    if (self != [super init]) {
>>        return;
>>    }
> 
> The opposite of ‘if (self = [super init])’ isn’t ‘if (self != [super init])’. 
> The correct code is:
> 
>       self = [super init];
>       if (self == nil)
>               return nil;
> 
>> I'm not smoking crack here, am I?  
> 
> We only have your word for it.
> 
>> Does this actually seem like a good idea?
> 
> 
> Of course it’s a good idea (minus the two glaring bugs).


Heh, yeah, it's been a LOOOONG week.  I certainly can't see through the glare 
too well.

Regarding Daniel's next email, yeah, I kind of really dislike the extra indent 
for the entire init function.  It just seems so wrong.

Glad I asked.  I'm certainly not the first person to come across this.  
Daniel's friend's solution seems good.  However, the !self comment shows the 
same error Simon points out below.

Also, Simon points out another error in my assumption.

> what if [super init] returned something different than self, yet not nil?
> 
> In that case, your code wouldn’t be correct, as a general rule...

Hmmm.  This little comparison does flip the BOOL.  

if (!(self == [super init]))

Anyway, thanks for the Friday feedback and observations.  

Cheers,
Alex Zavatone
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to