Re: Fortran templates



Jim Xia wrote:

The Fortran committee recognizes the need for generic programming in
the language. There was an effort in 2008 standard to solve the
problem by MACRO. But that feature was voted out due to its
complexity and also the fact it is based on a rather outdated
technology. I personally dislike the MACRO approach at all: it's a
clumsy tool that generates very convoluted code -- the readability is
very poor. I think there must be a better way to achieve that.

Resistance to templates in Fortran is likely by the standard body
since it'll hurt performance due to code-bloat. Fortran is known to
generate fast code that C++ can even dream of. Any feature
endangering that capability is not going to be an easy sell. That
also explains why coarrays are welcomed to the language while the
templates are still being talked about.

If we shoot for a limited version of templates (as compared to C++)
that minimizes its damage to speed, then I think we have a chance.

Bloat is an orthogonal problem to speed (which is not to say that it's not something to be concerned about, only that it's largely independent of performance), and as far as I know, C++ comes closest to Fortran for performance in heavily templated code.

From a C++ point of view, my sense is that the biggest issues with templates revolve around the complexity of the feature. I don't think there's all that much concern with code size, as I don't think user code typically sees more than one or two instantiations of a particular template.
.



Relevant Pages