So here, my take is Fortran 90 got off on the wrong foot when ALLOCATABLE
s and POINTER
s got introduced in a standard revision which also had generic interfaces. Thus when it came to disambiguation, Fortran 90 had statements such as:
where type, kind, and rank got considered which later, starting Fortran 2003, came to be referred to as TKR compatible
semantics.
I truly believe, with some intent and inventiveness of the part of standard bearers, Fortran 90 could have started off with consideration of type, kind, rank, and attribute in disambiguation, or what I refer to as KART compatible semantics given what I think is the order of importance in actual practice with generic procedures. So with this, Fortran 90 would have been like so:
.
interface sub
module procedure sub_a
module procedure sub_b
module procedure sub_c
end interface
,
subroutine sub_a( a, b )
integer, intent(in) :: a(:)
integer, intent(out) :: b(:)
.
subroutine sub_b( a, b )
integer, intent(in) :: a(:)
integer, intent(out), allocatable :: b(:)
.
subroutine sub_b( a, b )
integer, intent(in) :: a(:)
integer, intent(out), pointer :: b(:)
.
integer x(..), y(..)
call sub( x, y ) ! disambiguates to sub_a
.
integer u(..)
integer, allocatable, v(..)
call sub( u, v ) ! disambiguates to sub_b
.. and so forth
Now, this would not have given the practitioners the short-cut to readily invoke procedures with nonallocatable, nonpointer array received arguments with actual that have either of these. But instead of a ready short-cut, in this case it might have worked out better if some other syntactical sugar, say the use of ( .. )
, around the actual arguments was selected e.g.,
call sub( u, (v) ) ! disambiguates to sub_a due to `( .. )` around v denoting an expression a la ASSOCIATE construct
Oh well …
But I had very much wished for the Generics for Fortran 202Y to be designed around KART-compatible semantics, alas I failed.