← Back to context

Comment by bregma

5 days ago

FORTRAN had both functions and subroutines. A function returned a value and was invoked in an expression (eg. S=SIN(A)). A subroutine was invoked by calling it (eg. CALL FOPEN(FNAME, PERMS)).

I should probably just Google this, but how did you define the functions?

  •     C     -------- START OF FUNCTION -------    
              INTEGER FUNCTION INCREMENT(I)
              INCREMENT=I+1
              RETURN
              END
        C     -------- END OF FUNCTION -------

    • FORTRAN also had single-expression function definitions, e.g.

          ARGF(X, Y, Z) = (D/E) * Z+ X** F+ Y/G
      

      Naturally this is syntactically identical to an array element assignment, which is one of the many things that made compiling FORTRAN so much fun.

      4 replies →