This question has been prompted by a recent question about the assigned GOTO operator.
It appears that some early FORTRAN implementations supported a non-obvious construct: using an indexed variable in the
ASSIGN operator and the
GOTO operator, e.g.
ASSIGN 10 TO IGO(K) ... GOTO IGO(K)
This allowed to mimic recursive functions (with appropriately managed local variable frame, if needed) even on platforms with no call stack.
The following program compiles and executes correctly on PDP-11 UNIX V5:
Paul Nankervis - email@example.com Boot> boot rk0 @unix login: root # chdir /tmp # cat > fact.f integer st(100),ptr,f ptr=1 n=10 assign 10 to st(ptr) goto 100 10 print 1,n,f 1 format(' factorial of ', i2, ' is ', i10) stop 100 print 2,n 2 format(' called: factorial of ', i5) if (n.gt.1)goto 101 f = 1 goto st(ptr) 101 n=n-1 ptr=ptr+1 assign 102 to st(ptr) goto 100 102 continue print 3,n,f 3 format(' fact(',i2,') =', i10) ptr=ptr-1 n=n+1 f=f*n goto st(ptr) end # fc fact.f # ./a.out called: factorial of 10 called: factorial of 9 called: factorial of 8 called: factorial of 7 called: factorial of 6 called: factorial of 5 called: factorial of 4 called: factorial of 3 called: factorial of 2 called: factorial of 1 fact( 1) = 1 fact( 2) = 2 fact( 3) = 6 fact( 4) = 24 fact( 5) = 120 fact( 6) = 720 fact( 7) = 5040 fact( 8) = 40320 fact( 9) = 362880 factorial of 10 is 3628800 #
(an aside: allowing quoted strings instead of Hollerith style had been an early enhancement, apparently)
A BESM-6 FORTRAN compiler, directly derived from the CDC 1604 compiler, accepts the code and produces an identical result. A newer (post-1977) BESM-6 compiler rejects it.
G77 rejects the code as well:
fact.f:4: assign 10 to st(ptr) ^ Expression at (^) has incorrect data type or rank for its context
It looks like when FORTRAN was being standardized, the syntax was tightened.
The question is: Was the liberal reading of the syntax, allowing assigning labels to array elements, an "official" one, that is, originated by IBM, or was it an unrelated initiative, adopted by competing vendors (at least DEC and CDC)?