Skip to content

The State of Fortran Generics

everythingfunctional.wordpress.com
56 pointsmilancurcic3 comments
On HN

Comments

Interesting development, as Fortran already has support for some kind of genericity.

https://annefou.github.io/Fortran/modules/modules.html

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.