Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!linus!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.lang.c Subject: Re: default Message-ID: <788@bbncca.ARPA> Date: Wed, 20-Jun-84 10:30:52 EDT Article-I.D.: bbncca.788 Posted: Wed Jun 20 10:30:52 1984 Date-Received: Thu, 21-Jun-84 01:24:08 EDT References: <4289@edai.UUCP> <341@vu44.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 45 -------------------------------------------- > What does > > switch(i) { > ... > switch(j) { > ... > default: ... > } > } > > do if there is no case corresponding to i? > . > . > . > Or I could even add a 'goto default'......... > (Note: my C Ref Man doesn't say that default is a reserved word, > so using default as an ordinary label is perfectly legal) > > Jack Jansen, {philabs!decvax}!mcvax!vu44!jack Well, first off, you have a defective "C Ref Man", because the C Reference Manual in K&R clearly lists "default" as a reserved word (section 2.3, Keywords, page 180 of K&R). Secondly, what happens is clearly defined (section 9.7, Switch Statement): Any statement within the statement may be labeled with one or more case prefixes . . . There may also be at most one statement prefix of the form default: If no case matches and if there is no default then none of the statements in the switch is executed. The "default" in the example above is not a prefix of a "statement within the statement", but a prefix of a statement within a statement within the statement. The default will never be considered unless the switch(j) statement is being executed. The answer to the question is that the above fragment evaluates i, compares its value to any case constants (assumed to be in the ...), and then does nothing else. -- Morris M. Keesan {decvax,linus,wjh12,ima}!bbncca!keesan keesan @ BBN-UNIX.ARPA