|
|
|
|
|
by WalterBright
1256 days ago
|
|
I used to do `if (errno) goto err;` a lot. I eventually realized that nested functions did the job much nicer: void err() { printf("oops, we failed"); }
...
if (errno) return err();
This cleaned up a lot of my code. (The optimizer would of course inline the function, and the common tail merging would automatically convert it to the goto version in the optimizer. So this was cost-free.)Why C doesn't officially have nested functions is, well, that's C! |
|
It starts with one goto, then one more, then another.
The first goto is usually clever but then someone else arrives and hacks another one because they don't want to change the code too much.