(j3.2006) Question about submodule using its ancestor modue
Daniel C Chen
cdchen
Wed Nov 19 11:03:50 EST 2014
I agree with Reinhold that the code should be conforming. However, I think
the use association should override the host association. It should have
the same effect as
Program main
Use m
Contains
Subroutine sub()
Use m
End
End :
Thanks,
Daniel
XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
From: "Bader, Reinhold" <Reinhold.Bader at lrz.de>
To: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
Date: 11/19/2014 04:03
Subject: Re: (j3.2006) Question about submodule using its ancestor modue
Sent by: j3-bounces at mailman.j3-fortran.org
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
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20141119/02daef0e/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20141119/02daef0e/attachment.gif
More information about the J3
mailing list