Re: [OT][PB] ( x = y ) warning - switch behavior
Re: [OT][PB] ( x = y ) warning - switch behavior
- Subject: Re: [OT][PB] ( x = y ) warning - switch behavior
- From: Jim Witte <email@hidden>
- Date: Mon, 7 Jul 2003 23:41:45 -0500
I respectfully disagree. In my experience, using a single equals sign
in an if is Far more often an error than not, and in those cases which
aren't the compiler can be very easily silenced with an extra pair of
This is shamefully OT, but might just barely be considered germane to
the Obj-C standard..
This brings one of my biggest pet peeves with C (and C++, and Obj-C,
and Java, and Perl, and Transcript, and who knows what else): the
default fall-through behavior of the switch statement. I read
somewhere that 98% of the time, what the programmer wants is to have an
implied break statement. Basically the way Pascal implemented the case
statement.
The ONLY reason I can think for having default fall-through behavior
is if you want to test for multiple conditions, eg:
switch (x)
1: 2: 3:
doOptionOneAndTwo
break;
3: 4: [..]
But then the obvious solution is the one that Pascal used, eg:
case x of
[1-3]: doOptionOneAndTwo
3,4: [..]
Or you could have an optional pass or continue statement for the 2%
where you do want fall-through behavior. I'll never understand why the
C designers didn't do this. Of course now the design principle is so
embedded in the 'C-syntax methodology' that is used by so many
languages that it'll never change..
Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.