Invalid analogy

I Wish khan at milton.acs.washington.edu
Sun Mar 4 09:26:51 AEST 1990


In article <8222 at hubcap.clemson.edu>
billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu writes:

> From eaker at sunbelt.crd.ge.com (Charles E Eaker):

>> [In C] similar flow-of-control constructs do not terminate in 
>> similar ways.  If one is using the if statement, termination is
>> automatic.  If one is using the switch statement, a break is required.  

[his example, a nested loop/if/switch/etc.]

> Notice: "similar flow-of-control constructs".  Both the case and 
> the if statements execute different sections of code depending on
> the value of a controlling expression.  [...]

> This extreme similarity, unfortunately, does not extend to C's concept
> of how the two should be supported within the programming language. 

> Bill Wolfe, wtwolfe at hubcap.clemson.edu

I see C's if as an exclusive two-case switch.  If doesn't need break
because fallthrough in an if would be useless -- any code common to the
then and else clauses can be factored out of the if, since there are no
other cases.  "If", as a _special_ _case_ of switch, assumes a break;
would C be better if "then" required a break to prevent fallthrough to
the else?  That would be a consistent way to make them similar.
-- 
"indecipherable strangers handing out inexplicable humiliation and an
 unidentified army of horsemen laughing at him in his head ..."
                                                           -- Douglas Adams
Erik Seaberg (khan at milton.u.washington.edu)



More information about the Comp.lang.c mailing list