Comment by Tyr42
4 years ago
Goto based algorithms generally outperform looped algorithms.
(They're just more general, you can always implement a loop based algorithm using gotos, but not the other way around)
4 years ago
Goto based algorithms generally outperform looped algorithms.
(They're just more general, you can always implement a loop based algorithm using gotos, but not the other way around)
Not exactly. This is more an artefact of language design.
If you convert everything to continuation passing style, then every function call, tail call, recursion, etc. is just as expensive (and expressive) as a GOTO. This is, incidentally, the main "trick" or lightbulb moment in the classic Cheney on the MTA paper by Henry Baker [1].
Now if we're talking specifically in C, then absolutely! But while this intuition holds for C, it's not always true and doesn't have to be always true.
[1] https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.54...
That was a really good short read.