gotos
Henry Spencer
henry at utzoo.uucp
Sun Apr 24 11:23:22 AEST 1988
> You probably don't believe in "register" or "char ***", either.
I use the former frequently and would use the latter if it seemed indicated,
although I don't recall ever needing it.
> A language feature is there for a reason...
Language designers and standardizers do have to consider badly-written
existing code as such a reason, remember.
> ...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...
Believe it or not, some of us do not consider the Unix kernel a shining
example of wonderful programming (although it is mostly okay, and it does
work pretty well).
> Try the following some time. Replace all your "nifty" flags with "goto"
> statements, and profile both versions of the code...
If you read the paper by Geoff Collyer and myself in last year's winter
Usenix proceedings, I think you will realize that I know how to profile
things, and also how to make them run fast without assembler or gotos
(C News contains neither).
> then, disassemble
> both versions and grep for all branch instructions. Which has more
> REAL "goto"'s?
Personally, I don't care diddly-squat about how ugly the code coming out
of the compiler is. I don't usually read it. What I care about is the
cleanliness of the source code, which I do have to read, and the speed and
correctness of the object code. Turning clean human-readable notation into
ugly fast code is the compiler's *JOB*.
> ... 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.
If you use neither, the source code generally looks still better, and the
assembler might well improve too (if you care). I'm not sure I've ever
used a flag just to avoid a goto; certainly I haven't done it recently.
I believe in treating the disease, not the symptoms.
> The use of the "goto" statement is much profaned by ex-Pascal programmers
> who have almost, but not quite, seen the light...
Well, speaking for myself, I've never programmed in Pascal. I suppose I may
not have seen the light yet; I've only programmed in C for 13 years.
--
"Noalias must go. This is | Henry Spencer @ U of Toronto Zoology
non-negotiable." --DMR | {ihnp4,decvax,uunet!mnetor}!utzoo!henry
More information about the Comp.lang.c
mailing list