From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=5.0 tests=BAYES_05,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.lang.c:26534 comp.lang.ada:3381 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!mintaka!mit-eddie!uw-beaver!milton!khan From: khan@milton.acs.washington.edu (I Wish) Newsgroups: comp.lang.c,comp.lang.ada Subject: Re: Invalid analogy Summary: what are similar constructs? Message-ID: <2249@milton.acs.washington.edu> Date: 3 Mar 90 23:26:51 GMT References: <5750@crdgw1.crd.ge.com> <8222@hubcap.clemson.edu> Reply-To: khan@milton.acs.washington.edu (I Wish) Organization: Barbarian Driving School, University of Washington, Seattle List-Id: In article <8222@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes: > From eaker@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@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@milton.u.washington.edu)