FROM : Hans van der Meer
DATE : Sun Feb 10 23:26:05 2008
On 10 feb 2008, at 22:44, Jens Alfke wrote:
> It's possible to coalesce the first two lines into "if( self =
> [super initWithFoo: foo] )", but I avoid this because putting
> assignments inside 'if' or 'while' tests is a dangerous idiom ...
> it's very easy to type "==" instead of "=" and end up with a
> difficult-to-detect bug.
It is no problem if one takes care to phrase the if as:
if (nil != (self = [super init])){...}
I know, still more keystrokes, but programming safety is the more
important consideration here and I force myself to not being lazy.
By the way. Doing (nil !== ...) is a habit that saves one in comparing
to variables as in (nil == myvariable). Compare this to (myvariable ==
nil) that indeed is a bit dangerous.
I hope this comment is not too far off topic for this list -- so I
make this my last contribution on this subject.
Hans van der Meer
DATE : Sun Feb 10 23:26:05 2008
On 10 feb 2008, at 22:44, Jens Alfke wrote:
> It's possible to coalesce the first two lines into "if( self =
> [super initWithFoo: foo] )", but I avoid this because putting
> assignments inside 'if' or 'while' tests is a dangerous idiom ...
> it's very easy to type "==" instead of "=" and end up with a
> difficult-to-detect bug.
It is no problem if one takes care to phrase the if as:
if (nil != (self = [super init])){...}
I know, still more keystrokes, but programming safety is the more
important consideration here and I force myself to not being lazy.
By the way. Doing (nil !== ...) is a habit that saves one in comparing
to variables as in (nil == myvariable). Compare this to (myvariable ==
nil) that indeed is a bit dangerous.
I hope this comment is not too far off topic for this list -- so I
make this my last contribution on this subject.
Hans van der Meer
| Related mails | Author | Date |
|---|---|---|
| Scott Andrew | Feb 10, 18:18 | |
| Scott Andrew | Feb 10, 18:35 | |
| Adhamh Findlay | Feb 10, 19:41 | |
| John Newlin | Feb 10, 20:13 | |
| Hans van der Meer | Feb 10, 20:20 | |
| Quincey Morris | Feb 10, 20:29 | |
| Jens Alfke | Feb 10, 20:45 | |
| Wade Tregaskis | Feb 10, 20:50 | |
| Ricky Sharp | Feb 10, 21:01 | |
| Jens Alfke | Feb 10, 22:44 | |
| Hans van der Meer | Feb 10, 23:26 | |
| Paul Bruneau | Feb 10, 23:29 | |
| Uli Kusterer | Feb 10, 23:40 | |
| Paul Bruneau | Feb 11, 00:18 | |
| Scott Andrew | Feb 11, 00:56 | |
| Quincey Morris | Feb 11, 02:32 | |
| mmalc crawford | Feb 11, 02:49 | |
| Jens Alfke | Feb 11, 03:05 | |
| Bill Bumgarner | Feb 11, 03:28 | |
| Quincey Morris | Feb 11, 04:35 | |
| Jean-Daniel Dupas | Feb 11, 10:27 | |
| Jens Alfke | Feb 11, 17:08 | |
| Ben Trumbull | Feb 11, 23:58 |






Cocoa mail archive

