I just wondered if the hated goto
statement is as powerful as the comefrom
statement? In my opinion they are probably equal in their capabilities but I am not entirely sure on that. Is there any formal proof that they are equally powerful (or not equally powerful)?
For any who never heard of it: comefrom
is sort of a reversed goto
:
comefrom doom;
WriteLine("I will never stop executing!");
doom:
comefrom
is strictly more powerful than goto
.
Each program with goto
can be mechanically transformed into an equivalent comefrom
-only program, by, well, replacing each goto
with a corresponding comefrom
.
The reverse is not true. This program has no goto-only equivalent:
doom:
comefrom doom;
WriteLine("I will never stop executing!");
goto doom;
comefrom doom;
WriteLine("Guess my time has come!");
This program print the first phrase an unknown number of times, then the second phrase, and exit. This kind of non-determinism is not achievable with conventional programming languages that lack comefrom
.