5 ms·
The bit at the end about `goto` and Dijkstra is wonderfully written -- I almost wish it were a separate post so I could point people at it directly. An interes
by Twisol 7y ago
The bit at the end about `goto` and Dijkstra is wonderfully written -- I almost wish it were a separate post so I could point people at it directly.
An interesting note about that, by the way -- there is a notion of a "loop-nesting forest" in the literature, which is basically a way of taking a flowgraph with cycles and deriving a tree of loops, essentially recovering the "original" lexical structure of the loops. This works best when the flowgraph is so-called "reducible", for which the definition is slightly technical (and I don't have an excellent intuition for it myself). The upshot is that a CFG is reducible if you only use the usual "structured" control flow operators.
In the sense that you can recover lexical nesting from a reducible CFG, Dijkstra is right on the money: the dynamic behavior and the static behavior are in much closer correspondence. But once you add goto, you admit the possibility of irreducible CFGs, and it's no longer clear how to recover any hierarchical structure. (There are several types of loop-nesting forest out there, but they focus on recovering different aspects -- there's no perfect solution.)