I think the existing support more like "function overloading" in C++ - you make some subroutine/function name which calls the appropriate subroutine/function with the correct argument types.
Unfortunately the existing support isn't like proper generics. In my Fortran code I use C macros (#include) to avoid repeating big blocks of generic code for each data type. For example, I needed to do this for a sort routine which could act on different data types. This is very clumsy, so any proper generics will be welcome. Hopefully there will be a STL-like library which could be based around these generics.
> I think the existing support more like "function overloading" in C++ - you make some subroutine/function name which calls the appropriate subroutine/function with the correct argument types.
I agree, this appears to support ad hoc polymorphism. You could carefully use this to deliver only the behaviour you'd want from parametric polymorphism in some cases, but the ergonomics are poorer.
3 comments
[ 3.1 ms ] story [ 19.7 ms ] threadhttps://annefou.github.io/Fortran/modules/modules.html
Unfortunately the existing support isn't like proper generics. In my Fortran code I use C macros (#include) to avoid repeating big blocks of generic code for each data type. For example, I needed to do this for a sort routine which could act on different data types. This is very clumsy, so any proper generics will be welcome. Hopefully there will be a STL-like library which could be based around these generics.
I agree, this appears to support ad hoc polymorphism. You could carefully use this to deliver only the behaviour you'd want from parametric polymorphism in some cases, but the ergonomics are poorer.