Comment

Comment by Mikhail_Edoshin

'goto' is more universal and may make cleaner code even in loops. E.g. to loop backwards without 'goto' one has to resort to an idiom like that:

    for (i = n; i--; )
and I wouldn't say this idiom is that clear. You can get used to it, of course. Another interesting case is printing a list of items with separators. C loop constructs are biased cases of frequently used loops but they do not cover all the possible cases. 'goto' is unbiased.

A similar case are Python loops. There are “Pythonic” ways:

    for item in iterable
        ...
They look sweet but are useful only in some cases. E.g. if you need to modify `iterable`, the Pythonic way won’t work. There are Pythonic workarounds, but they may involve copying a whole iterable, which is hardly a good idea. But there is also a less Pythonic way:

    i = 0; n = len(iterable)
    while i < n:
        ...
This works all the time and serves all possible cases.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton