I don't know how it worked back in the day, so I've no idea what he was referring to.

But, take JS:

var x = 5;
var foo = function(y) { console.log(2); };
var y = 6;
foo(); // is this not in essence a goto statement?

If not, then what was different about GOTO statements?

Would Dijkstra have opposed JS on these grounds?

3

There are 3 best solutions below

0
On BEST ANSWER

In your example, you are calling a subroutine rather than unconditionally and permanently transferring the flow of control (which is what goto does).

If you put code after foo();, that code would get executed after foo() is called.

0
On

No, this is in essence a "GOSUB" statement. Did you read the original paper? IMHO Dijkstra was offended by "smearing" state all over your code.

2
On

This is a jump statement, not a GOTO statement. Therefore, it does NOT create spaghetti code.