Put your code where your mouth is (was Re: gotos)

Henry Spencer henry at utzoo.uucp
Wed Apr 20 17:20:00 AEST 1988


> # Also left as an exercise for the reader is finding the bug in Knuth's
> # hash-table-search code.

For those who don't feel like studying the code, the bug is that the
code infinite-loops if the table is full.  One wonders whether Knuth would
have noticed this if he'd tried to avoid the gotos.

> Mr. Spencer, put your code where your mouth is.  For each goto example in
> Knuth, show us how you would code it to run equally efficiently without
> gotos.  Fair enough?

To put it bluntly, it's not worth my time.  In most cases the obvious goto-
free code is just as efficient as Knuth's, given a modern compiler.  Much
of what Knuth is discussing can be seen as ways of hand-coding the sort
of optimizations that modern compilers do without being asked.
-- 
"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