[Patch,Fortran] Add polymorphic type support (OOP, RTTI) - merge from Fortran-dev branch
Salvatore Filippone
salvatore.filippone@uniroma2.it
Wed Sep 30 12:15:00 GMT 2009
Il giorno mer, 30/09/2009 alle 13.59 +0200, Paul Richard Thomas ha
scritto:
> Dear Salvatore,
>
> >>I am not entirely sure that this would be standard compliant in
> >>fortran. We have discussed the matter but have not really concluded.
> >>My tilt is that all subtypes should be known at compile time because
> >>they should all be use associated. In fact, I am reminded that we
> >>need to warn that attempts to define classes in interfaces will not
> >>work at present.
> >
> > If I understand what you are saying, you are wrong here; having a code
> > compiled once, and work with type extensions as they are added without
> > recompilation, is arguably the main point (if not quite the whole
> > point) of polymorphism.
>
> Indeed, I agree completely with that. However, fortran requires a
> definition of the declared type or the type that is being extended.
> This is done with a module file, whether or not the code is already
> compiled. Otherwise, I do not know how the derived type definitions
> can be supplied to the code that contains the extension.
>
Ah, I see what you mean.
Yes, the "base type" has to be known at compile time.
Or, to take into account (somewhat) pathological cases such as CLASS(*),
the code may only invoke methods that are known through the "base type"
level at compile time, and possibly overridden (sp?) by the derived
type; the CLASS(*) variable you can do almost nothing with, except enter
a SELECT TYPE or call a subroutine.
> > reference as an added reference for further discussion.
>
> ...anyway, I'll go and take a look at the section 16.9 in MRC. :-)
Having recenty had Malcolm Cohen (the C) agree with my code and
declaring a bug in the NAG compiler boosted my confidence, nonetheless I
can recommend reading that book again, I guess it can do no
harm ... :-)
Salvatore
More information about the Fortran
mailing list