Parametric polymorphism: Difference between revisions

Content added Content deleted
Line 418: Line 418:


=={{header|Fortran}}==
=={{header|Fortran}}==
Fortran does not offer polymorphism by parameter type, which is to say, enables the same source code to be declared applicable for parameters of different types, so that a contained statement such as <code>X = A + B*C</code> would work for any combination of integer or floating-point or complex variables as actual parameters, since exactly that code would be workable in every case. Further, there is no standardised pre-processor protocol whereby one could replicate such code to produce a separate subroutine or function specific to every combination.
Fortran does not offer polymorphism by parameter type, which is to say, enables the same source code to be declared applicable for parameters of different types, so that a contained statement such as <code>X = A + B*C</code> would work for any combination of integer or floating-point or complex variables as actual parameters, since exactly that (source) code would be workable in every case. Further, there is no standardised pre-processor protocol whereby one could replicate such code to produce a separate subroutine or function specific to every combination.


However, with F90 came the MODULE protocol with facilities suitable for defining "generic" subroutines or functions, or so it appears: <lang Fortran> MODULE SORTSEARCH !Genuflect towards Prof. D. Knuth.
However, with F90 came the MODULE protocol with facilities suitable for defining "generic" subroutines or functions, or so it appears: <lang Fortran> MODULE SORTSEARCH !Genuflect towards Prof. D. Knuth.