Is general resolution possible in Fortran with unlimited polymorphic objects

When trying to overload subprograms using common interfaces or combining modules or procedures associated with type binding, you must consider that any of the procedures with the same common name must have distinguishable or incompatible arguments.

When using unlimited polymorphic objects, you can quickly run problems like this in this incredible tutorial:

INTERFACE foobar SUBROUTINE foo(x) INTEGER :: x END SUBROUTINE foo SUBROUTINE bar(x) CLASS(*) :: x END SUBROUTINE bar END INTERFACE foobar 

Here foo(x) conflicts with bar(x) , since the argument bar can also be INTEGER .

This particular problem can be solved with the SELECT TYPE construct in a new routine that replaces the common interface:

 SUBROUTINE foobar(x) CLASS(*) :: x SELECT TYPE (x) TYPE IS INTEGER CALL foo(x) CLASS default CALL bar(x) END SELECT END SUBROUTINE foobar 

However, sometimes such designs can become tedious and undesirable.

Are there other ways to implement this specialization without using the SELECT TYPE construct?

+7
fortran
source share

No one has answered this question yet.

See related questions:

5
Fortran procedure pointer to routines in a derived type
5
run-time polymorphism in fortran 2003
4
Are there additional subroutine calls with polymorphic derived types when the type is known at compile time?
3
Overloading Related Types in Fortran 2003
3
Using an unlimited polymorphic type for array operation in Fortran 03/08 (gfortran compiler)
3
Warnings with a Fortran common interface containing procedures whose dummy argument is an unlimited polymorphic pointer
2
Distinguishing generics in Fortran other than type / species / rank
one
Array of unlimited polymorphic pointers as a dummy variable
0
Common name for distinguishable pointers

All Articles