Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utcsrgv.UUCP Path: utzoo!utcsrgv!dave From: dave@utcsrgv.UUCP (Dave Sherman) Newsgroups: net.lang.c Subject: Why not allow "default" as a label? Message-ID: <2076@utcsrgv.UUCP> Date: Wed, 24-Aug-83 11:31:18 EDT Article-I.D.: utcsrgv.2076 Posted: Wed Aug 24 11:31:18 1983 Date-Received: Wed, 24-Aug-83 11:39:32 EDT Organization: The Law Society of Upper Canada, Toronto Lines: 43 It would be nice if I could say "goto default;" within a switch statement. I realize "default:" isn't a label, but is there any reason why it shouldn't be? Here's the application (part of a routine looking for a yes or no answer): loop: . . . switch(*p) { case 'y': return(1); case 'n': return(0); case 'm': if(strncmp(p+1, "aybe", 4) printf("Very funny. "); ============> goto deflt; <==================================== case 'o': if(*(p+1) == 'k') return(1); /* fall through */ default: deflt: printf("Please answer yes or no.\n"); goto loop; } Obviously, I would like to avoid the use of deflt. (This is on vanilla v7 UNIX on an 11/23, but the 4.1bsd compiler also rejects "default" as a label.) Is the problem related to the fact that there can be multiple defaults within a routine? I know I can solve the problem by putting the printf outside of the switch, in this case. That's not the point. I've run into the problem in other places too. Dave Sherman The Law Society of Upper Canada Toronto -- {allegra,cornell,floyd,ihnp4,linus,utzoo,uw-beaver,watmath}!utcsrgv!lsuc!dave