goto
in
PlusCal not Harmful
In 1968, Dijkstra published a highly influential note titled Go To
Statement Considered Harmful, persuasively arguing that the
goto
statement should be banished from programming
languages because it makes programs harder to understand.
I don't disagree with his argument. However, PlusCal is an
algorithm language, not a programming language; and algorithms are not
programs.
One measure of the complexity of an algorithm written in PlusCal is
the number of labels it has. More labels mean more reachable
states, which make both understanding and model checking an algorithm
more difficult.
It appears impossible to write algorithm 1BitNoDeadlock
with as few labels if while
is the only construct for
writing a loop. The goto
statement is the simplest
way I know to allow minimizing the number of labels in all
situations.
There is no harm in a sensibly used goto
, like the one in
1BitNoDeadlock
. Few of the algorithms I've written
have a goto
, but on occasion it can be quite useful.