gotos

Every system needs one terry at wsccs.UUCP
Wed Apr 20 13:21:42 AEST 1988


In article <1988Apr11.201934.20594 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
> Sorry, I consider the remark well-justified and will not apologize.  If
> you read my other postings on the subject, you will see that I consider
> the use of gotos, especially the frequent use of gotos, to be a sign of
> poor organization and "coding before thinking".  Given this opinion, it
> is hardly surprising that I would be reluctant to buy software from an
> organization which endorses routine use of gotos.

#ifdef FLAME

You probably don't believe in "register" or "char ***", either.  A language
feature is there for a reason, or it rots and falls off, much like a human
cerebellum.  Coding before thinking is when all your local variables are
named "foo" and all your global variables are named "fee", "fie", "foe", and
"fum".  Your functions are named "func1", "func2", etc., and your comments
consist of "Begin program" and "End program".  This is the result of not
thinking.  Use of conditional flags which may have to be loaded from memory
is thinking twice and saying "think think ... click click".

The use of the "goto" statement is much profaned by ex-Pascal programmers
who have almost, but not quite, seen the light.  These are the same people
who do:

#define	BEGIN		{
#define	END.		}
#define	END		}
#define	REMARK(x)	/* (x) */
#define	THEN
#define IF		if

and

	IF (cond) THEN
	BEGIN
		...
		...
	END

They are the same people who who use

	if (cond)
	{
	}

and	#define otherwise default
	switch (val)
	{
		case 1:
			...
			...
		case n:
		otherwise:
	}

and	int function()

Instead of

	if( cond) {
	}
	
and	switch( val) {
	case 1:
		...
		...
	case n:
	default:
	}

and	int
	function()

I like to call these people NOT-C programmers (say it out loud :-)

They are the people who do not realize that

	grep goto /usr/src/uts/3b2/*/*.c | wc

yeilds:

	308	992	8411

...308 "goto"'s in the UNIX kernel. (I checked... NONE were comments).

I thinks this adequately justifies the use of "goto"'s in commercial
programming, at least for those programs expected to PERFORM like a
commercial program.

Try the following some time.  Replace all your "nifty" flags with "goto"
statements, and profile both versions of the code... then, disassemble
both versions and grep for all branch instructions.  Which has more
REAL "goto"'s?

#else
	I'm not saying that "goto"'s should be used in place of all loop
flags, but it certainly seems to make code a lot more readable if you don't
have to use a 264 column terminal.  If you use "goto"'s in place of flags
which are modified in one place only for the express purpose of avoiding a
"goto", you certainly clean up the assembly code, as well.
#endif


| Terry Lambert           UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry |
| @ Century Software        OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry    |
| SLC, Utah                                                                   |
|                   These opinions are not my companies, but if you find them |
|                   useful, send a $20.00 donation to Brisbane Australia...   |
| 'There are monkey boys in the facility.  Do not be alarmed; you are secure' |



More information about the Comp.lang.c mailing list