Xref: utzoo comp.lang.c:9425 comp.lang.misc:1453 Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!bloom-beacon!athena.mit.edu!peter From: peter@athena.mit.edu (Peter J Desnoyers) Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: gotos Message-ID: <4678@bloom-beacon.MIT.EDU> Date: 17 Apr 88 02:57:01 GMT References: <1988Apr8.183815.3187@utzoo.uucp> <449@goofy.megatest.UUCP> <3470@bunker.UUCP> <751@l.cc.purdue.edu> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: peter@athena.mit.edu (Peter J Desnoyers) Organization: Massachusetts Institute of Technology Lines: 37 In article <751@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >When your optimizing compiler can convert case switches with case numbers >generated into the more efficient code such as I would write, I will consider >eliminating those gotos. I don't know about optimizing compilers, but I've heard horror stories of non-optimizing compilers using jumptables for switch statements. (Oh no!! Why does "switch (n) {case 0: foo(); case 20000: bar();}" generate an 80k executable?) It may have been an older VMS compiler. I dunno... Personally, I think that doing such grevious harm to the source code in the name of 'optimizing' is off the mark. The time spent writing and maintaining that code could have been spent (1) buying an optimizing compiler; (2) writing it in assembler; or (3) convincing your boss to spring for a faster machine. Perhaps a better thing than docking people's pay for 'goto's would be a compiler that put a delay in with every goto. Ten or twenty nop's should be about right. Then people would only use goto when it was really needed for stylistic reasons. btw, my favorite reason for using goto - to cope with the problem that the same word (break) is used to terminate loops and to signal the end of a section of a switch. Thus you can write "if (foo) break;", but you may have reason to write: (what you want to write: ) while (foo) while (foo) switch (bar) switch (bar) { { case n: case n: goto (end_while); break; break; esac; /* or whatever */ } } end_while: Peter Desnoyers peter@athena.mit.edu