That changed in the 1950s with the development of symbolic languages — in particular the ‘formula translation’ language Fortran, developed by John Backus and his team at IBM in San Jose, California.
module test_m
implicitnonetype :: base_t
integer :: n =0containsprocedure :: pri, prr
generic :: pr => pri, prr
end type base_t
containssubroutine pri(me, i)
class(base_t), intent(in) :: me
integer, intent(in) :: i
integer :: k
print*, (i, k =1, me%n)
end subroutine pri
subroutine prr(me, x)
class(base_t), intent(in) :: me
real, intent(in) :: x
integer :: k
print*, (x, k =1, me%n)
end subroutine prr
end module test_m
program multiple_dispatch
use test_m
implicitnonetype, extends(base_t) :: deriv_t
real :: x =99.0end type deriv_t
class(base_t), allocatable :: t(:)
integer :: i
allocate(t(2))
t(1) = base_t(3)
t(2) = deriv_t(2, 1.0)
do i =1, 2call t(i)%pr(i)
call t(i)%pr(real(i))
end doend program multiple_dispatch
実行結果
Compiling with Intel(R) Visual Fortran Compiler 19.1.3.311 [IA-32]...