Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That is eliding quite a bit of the actual quote, “from one function into another,”.

The goto being spoken about here is the unconstrained type that allows for both modification of jump location during run time and jumping in the whole address space of either program or system.



The goto being written about is something that cannot jump even between ifs and loops, clearly. I.e. not the C goto, but perhaps something severely restricted, like the Common Lisp tagbody/go.


The inability to jump between functions is the main point. It is a sequence where I meant one goto doing all of them at once, not a choice list.

Also there are a few quirks here and there in a few languages, but it would break the flow to stop and enumerate the ones I know, plus I'd still miss some.

C is quite unruly, as it dates back to when this was a live debate, and this is one of the ways it being "portable assembly" is a reasonable statement. Duff's device is not possible in almost any other language. ISTR one other, but I'm not sure what it was... I may even be thinking about this: https://www.perlmonks.org/?node_id=388976 and that's 2004, not sure if perl can do that anymore.


I do not believe the article is correct, then. Dijkstra's goto paper squarely applies to the C local goto. The subject of the paper is not specifically machine language branch instructions that can go anywhere, or something like the global goto in line numbered BASIC (a language he did revile, claiming that it damages the brain).

I'm looking at the paper again. It clearly states that goto should be abolished from higher level languages.

Note that Dijkstra also lumps the repetition statement (while B repeat A / repeat A until B) with goto, and then carefully argues why that is an acceptable use of goto, namely that it is susceptible to analysis by induction.

I can't see how I can reach a conclusion other than that, yes, C has a goto of a type that Dijkstra considered harmful.

Some have argued that forward goto in C is easily analyzable, since it doesn't create loops. There are coding standards that permit forward goto, but not backward goto. What Dijkstra would have thought about the inclusion of a forward-restricted goto in a HLL is anyone's guess.

A C forward goto could jump from the middle of one loop into the middle of another one, though. Simply being forward isn't enough to ensure a certain property of the function's control flow graph. This is written about extensively in the Dragon Book.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: