(j3.2006) Question about submodule using its ancestor modue
Bader, Reinhold
Reinhold.Bader
Wed Nov 19 04:03:21 EST 2014
Hello Bill,
my take is that the code is conforming, and that host association overrides
use association in this context. Because the module must anyway be compiled
before the submodule is, there doesn't appear to be a circularity problem.
I don't think ambiguities can arise (consider the analogous case
m1 uses b
m2 uses b
a uses m1 and m2
).
The case of indirect referencing is actually the interesting use case: Say you have
an abstract type in m1. This will typically be extended in some other
module m2, which needs to use m1. On the other hand, for full dependency
inversion, m1 needs to provide e.g. a procedure to create an object. This often
will imply that the complete inheritance tree must be dealt with, i.e. the procedure
specifically needs type information stored in m2. Hence, to avoid circular module
references, the procedure needs to be put into a submodule, which uses m2, and therefore
indirectly also m1.
Cheers
Reinhold
> -----Urspr?ngliche Nachricht-----
> Von: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-
> fortran.org] Im Auftrag von Bill Long
> Gesendet: Mittwoch, 19. November 2014 00:06
> An: fortran standards email list for J3
> Betreff: (j3.2006) Question about submodule using its ancestor modue
>
>
> Is the USE statement in the submodule below conforming?
>
> module m1
> real :: x
> end module m1
>
> submodule (m1) bar
> use m1
> end submodule bar
>
> Option 1: It is OK, since the USE of m1 in the submodule blocks all host
> association of objects in module m1, so no ambiguity.
>
> Option 2: No. The submodule is an extension of m1 and this amounts to a
> recursive access to the module.
>
>
> I suspect Option 2 would promote better code and fewer mistakes. Particularly if
> "use m1" were instead "use m2" where m2 included a USE of m1.
>
>
> Cheers,
> Bill
>
>
> Bill Long longb at cray.com
> Fortran Technical Suport & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9142
> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
>
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
More information about the J3
mailing list