gotos

Tainter tainter at ihlpg.ATT.COM
Sat Apr 9 09:49:13 AEST 1988


In article <4347 at ihlpf.ATT.COM>, nevin1 at ihlpf.ATT.COM (00704a-Liber) writes:
> In article <2556 at ttrdc.UUCP> levy at ttrdc.UUCP (Daniel R. Levy) writes:
> |I know this battle is an old chestnut, but for the record do you guys believe
> |that superfluous flags and great big if-then statements are truly superior
> |to the goto?  (And the break, which is a goto by another name.)  E.g.:
> |
> |	while (loopcond) {
> |		for (i=0; i<limit; i++)
> |			if (frob(i) == TRUE)
> |				goto loopagain;	/* nice and CLEAN!!! */
> |		.../* lots and lots of code over many pages */...
> |loopagain:	;
> |	}
> Opinion:  this is an example of FORTRAN disguised as C.
>  In this particular case, using a continue statement
> inside in your Fortran-type example instead of a goto is much more preferable.

Except of course that that wouldn't work since it is nested under a second loop.
This is the only alternative to using a flag on the lines of the alternative
code.

[ Flag riddled code at indentation >> removed ]
> Opinion:  this is an example of Pascal disguised as C.

>  _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194

People, listen closely, GOTOs are not inherently bad.  If used carefully
as in this example they are quite reasonable and really not hard to follow.
Of course, they would be much harder to understand if they didn't use
mnemonics and instead used numbers ala Pascal or ForTran.

--j.a.tainter



More information about the Comp.lang.c mailing list