gotos

Daniel R. Levy levy at ttrdc.UUCP
Fri Apr 8 08:31:30 AEST 1988


In article <4307 at ihlpf.ATT.COM>, nevin1 at ihlpf.ATT.COM (00704a-Liber) writes:
> In article <1988Apr5.213343.1528 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
> 
> >And once in a long while, there is no better way.  A loooong while.
> 
> Agreed.  Although I feel that most of the uses of GOTO in C these days
> occurs in the output of something like LEX and YACC, where I really don't
> mind it.  Just as long as 'mere mortals' try to avoid using it.

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:	;
	}

versus

	while (loopcond) {
		boolean_flag=FALSE;
		for (i=0; i<limit; i++) {
			if (boolean_flag == TRUE) {
				;	/* spin uselessly */
			} else if (frob(i) == TRUE) {
				boolean_flag=TRUE;
			}
		}
		if (boolean_flag==FALSE) {
			...
			/* lots and lots of code over many pages */
			...
		}
	}
-- 
|------------Dan Levy------------|  Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
|         an Engihacker @        |  	<most AT&T machines>}!ttrdc!ttrda!levy
|     AT&T Data Systems Group    |  Disclaimer?  Huh?  What disclaimer???
|--------Skokie, Illinois--------|



More information about the Comp.lang.c mailing list