I've always wondered why goto is actually considered harmful. I really should read the original paper by Djikstra...
int parse(void)
{
Token tok;
while ((tok = gettoken()) != END)
{
while (!shift(tok))
if (!reduce(tok))
return ERROR;
}
return ACCEPT;
}
I will say that any language without goto, or where the use of goto is discouraged, should at least provide guaranteed tail-call elimination as an alternative. In this case the gotos could easily be converted into loops, but not every algorithm is so accommodating.[0]: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103...