The final word on GOTO (Don't I wis
Guy Greenwald
ggg at sunquest.UUCP
Tue Oct 10 01:32:23 AEST 1989
The structure
switch(c) {
case 'd':
...
goto something;
case 'u':
...
goto something;
...:
...
goto something;
something: /* Where's the default? */
}
can easily be replaced with
switch(c) {
case 'd':
...
something();
break;
case 'u':
...
something();
break;
...:
...
something();
break;
default:
...
break;
}
with no loss of clarity. Other transformations are possible, too.
The fact that some standard library implementation uses it isn't
convincing, either. I had to write my own strpbrk for VAX C because
the standard library routine performed miserably for the long
strings my code was processing (10K+). Useful routines can be
poorly implemented.
The first implementation given above will execute slightly faster than
the second, but why is it "easier to read?" I can't see that the
goto's are really necessary. (something() could be implemented as a
macro if it needs to be faster.)
More information about the Comp.lang.c
mailing list