4 ms·
In FORTRAN IV, multiple return labels could be passed to a subroutine. This was carried into PL/I. In FORTRAN 66, this was not supported. But, FORTRAN IV and 66
by ratboy666 5y ago
In FORTRAN IV, multiple return labels could be passed to a subroutine. This
was carried into PL/I. In FORTRAN 66, this was not supported. But, FORTRAN IV and 66 both support assigned go to, which can be used to replace this -- WATFIV supported this (local routines that use ASSIGN, with a bit of syntax sugar).
Note that this is a LONG time ago (mid sixties)...
- ratboy666 5y agoAnd... for reference. In my Microsoft F80 github string repository: https://github.com/ratboy666/string https://github.com/ratboy666/string (Microsoft F80 was a FORTRAN 66, slightly subset compiler -- no COMPLEX that Microsoft sold from the late 70s to early 80s). In there find pop.mac which is a short 4 byte assembly routine to discard a stack level. That can be used as follows: ASSIGN 1 TO I -- STORE ADDRESS OF LABEL 1 TO I CALL F(I) -- PASS I TO SUBROUTINE F ... -- WE WILL NEVER GET HERE 1 ... SUBROUTINE F(I) EXTERNAL $POP INTEGER $POP JUNK = $POP(0) -- REMOVE RETURN ADDRESS GO TO I -- GO TO ASSIGNED LABEL I END The ASSIGN command puts the address of label 1 into INTEGER I GO TO I then transfers to that location. Note that we can pass I into the SUBROUTINE, use $POP to remove a stack level (the return address), then jump to the variable. Scheme is nicer, which continuations, of course, but that hadn't been considered yet... The ASSIGN was deleted as a feature in FORTRAN 95 -- obsolescent by FORTRAN 90. I guess "very very old-school". Now, the FORTRAN 66 standard doesn't mention if something like this is allowed... but, since no stack was involved in early implementations, and recursion was not allowed, I imagine that it would work more widely than might otherwise be expected.