On 10 May 2010, at 16:49, Thomas Wetmore wrote:

> This is the initializer pattern I settled on a few years back:
> 
> - (id) init...
> {
>    if (!(self = [super init])) return nil;
>    ...
>    return self;
> }
> 
> Trillions of calls later I can report upon its serviceability.
> 
> I come from an old school, formed in the mid 60's, the Savers Institute for 
> Indentation Levels and Code, when Fortran on punch cards was de rigueur. My 
> graduate work was done at the Bell Labs Institute of Advanced Obfuscation 
> when C was cool. Both schools have since lost their raison d'être, and are 
> sometimes ridiculed, but old alumni still cherish their dogmas.

Just to add to the heap of style opinions...

I personally really dislike this one, for two reasons:
1) I hate that in C a statement can be an expression, it's not immediately 
clear when and how it'll be executed, and it's not immediately clear that your 
if statement might have a side effect.  Keeping if statements free of side 
effects is good.
2) While using a pointer in a comparison is not a type error in C, it certainly 
is in my brain – pointers and booleans are not the same thing.

Because of those two reasons I use:

- (id)init
{
  self = [super init];
  
  if (nil != self)
  {
    ...
  }
  
  return self;
}

Bob_______________________________________________

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

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

Reply via email to