(j3.2006) (SC22WG5.5622) Interpretations straw ballot 11
Van Snyder
Van.Snyder
Tue Dec 22 18:47:31 EST 2015
The following Fortran 2008 interpretations are being balloted:
Yes No Number Title
--- -N- F08/0128 Is recursive USE within a submodule permitted?
-Y- --- F08/0138 Type extension in submodules
-C- --- F08/0139 Is the name of an external procedure that has a
binding label a local identifier?
-Y- --- F08/0140 Assign to deferred-length coindexed character variable
-Y- --- F08/0141 Can a statement function have a variable-length PDT
result?
-Y- --- F08/0142 Is useless module extension permitted?
-Y- --- F08/0143 May a pure procedure have an INTENT(OUT) polymorphic
component?
-Y- --- F08/0144 Is nonadvancing I/O allowed during execution of DO
CONCURRENT?
Reason for NO vote on F08/0128:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Upon reflection, I prefer an answer very similar to Option 1 in 15-208.
A proposed revision is attached.
The questions are simplified and combined.
I vacillated whether to change the edit for [100:12], viz.
"where it is accessed by host association"
to
"where it is not accessed by use association"
to try to make it clearer that construct association is not involved.
Ultimately, I did not change it, because both versions might be
perversely interpreted in that context. Perhaps some work is needed
here.
The edit for NOTE 11.7 is revised simply to draw attention to 5.3.15 to
refer to it by number instead of repeating material therein.
An edit is provided for [443:36-37] to revise the first sentence of the
second paragraph of 16.5.1.4p2, to make it clear that the entity B is
still accessible, albeit by use association:
"If an entity that is accessed by use association has the same
nongeneric name as a host entity, the host entity is not
accessed by host association by that name."
("... the host entity is inaccessible by that name" could be perversely
interpreted to mean the entity is entirely inaccessible by that name,
i.e., neither by host nor use association. The problem is the word
"entity.")
This edit would also clarify the situation wherein a host scoping unit
and an internal scoping unit also access the same entity by the same
name by use association (no submodules involved). I hope this doesn't
need another interp, something like
module M1
real, public :: X = 66
end module M1
module M2
use M1, only: X
contains
subroutine S1
use M1, only: X
implicit NONE
X = 42
end subroutine S1
subroutine S2
use M1, only: X
X = 42
end subroutine S2
subroutine S3
call S2
print *, X
end subroutine S3
end module M2
program P
use M2, only: S3
call S3
end program P
Is the assignment to X in S1 conforming? Assuming the program conforms,
what is printed by the PRINT statement in subroutine S3, i.e., is the
assignment to X in S2 an assignment to the entity in M1, or is X a local
entity in S2? According to 16.5.1.4p2, "If an entity that is accessed
by use association has the same nongeneric name as a host entity, the
host entity is inaccessible by that name." This could be interpreted to
mean that the entity X is not accessible in S1 or S2, neither by use
association nor by host association.
Comment on F08/139:
~~~~~~~~~~~~~~~~~~~
Even though the title of the interp mentions "external procedure," I
agree with Malcolm Cohen that inserting "containing the external
subprograms" after the word "fragment" occurring at the beginning of the
"QUESTION" section clarifies the question.
-------------- next part --------------
J3/16-nnn
To: J3
From: Van Snyder
Subject: Interp of USE and submodules
Date: 2015 December 23
----------------------------------------------------------------------
NUMBER: F08/0128
TITLE: Is recursive USE within a submodule permitted?
KEYWORDS: SUBMODULE, USE
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
Consider
Module m2
Real, Private :: a
Real, Protected :: b
...
End Module
Submodule(m2) subm2
Contains
Subroutine s
Use m2
Implicit None
a = 3
b = 4
End Subroutine
End Submodule
Q1. The module m1 is referenced from within its submodule SUBM2. Is
this standard-conforming?
Note that the "submodule TR", Technical Report 19767 contains, an edit
with the normative requirement:
"A submodule shall not reference its ancestor module by use
association, either directly or indirectly."
along with a note which says
"It is possible for submodules with different ancestor modules to
access each other's ancestor modules by use association."
It also contains an edit to insert the direct reference prohibition
as a constraint.
However, none of this text appears in ISO/IEC 1539-1:2010.
The Introduction simply comments that submodules are available, but
not that they have been extended beyond the Technical Report that
created them.
Q2. In submodule SUBM2, procedure S references M2 by use association.
Is "A" still accessible by host association?
Q3. Procedure S attempts to assign a value to B, which is accessed by
use association, but has the PROTECTED attribute. Normally, this
attribute prevents assignment to variables accessed by use association.
Is the assignment to "B" standard-conforming?
DISCUSSION:
The prohibition against a submodule accessing its ancestor module by use
association appears in the early drafts of Fortran 2008, up to 08-007r1.
Then it was modified by paper 08-154r1 creating a UTI (because the
modification was broken), and finally the requirement was completely
removed by paper 09-141.
ANSWER:
A1. Yes, the example is conforming. An edit is supplied to add this
extension to the Introduction, and to add normative text to clause
11 to make this completely unambiguous.
A2. Yes, A is still accessible by host association.
Subclause 16.5.1.4 paragraph 2 states
"If an entity that is accessed by use association has the same
nongeneric name as a host entity, the host entity is
inaccessible by that name."
This does not apply since A is not accessed by use association
(because it is PRIVATE and therefore not accessible by use
association, according to the final sentence of the second paragraph
of 5.3.2). Therefore, A can still be accessed by host association.
An edit is provided to revise the referenced sentence to make it
clear that the entity is accessible by use association but not host
association, rather than being completely inaccessible.
A3. No, the assignment to B is not conforming because, according to the
first sentence of the second paragraph of subclause 16.5.1.4, it is
accessed by use association, and therefore violates constraint C551
which states
"A nonpointer object that has the PROTECTED attribute and is
accessed by use association shall not appear in a variable
definition context..."
An edit is provided to add an explanation of this.
EDITS:
[xv] Introduction, p2, first bullet,
After "Submodules provide ... for modules."
Insert new sentence
"A submodule can reference its ancestor module by use
association."
[100:12] Second paragraph of 5.3.15 PROTECTED attribute, insert this
text immediately after the word "descendants" (i.e. before the comma)
"where it is accessed by host association".
[272:23] First paragraph of 11.2.2 The USE statement and use
association, after
"A module shall not reference itself, either directly or
indirectly."
Append to paragraph
"A submodule is permitted to reference its ancestor module by
use association. "
[273:2+4] Same subclause, NOTE 11.7, append
"If a submodule accesses a PROTECTED entity from its ancestor module
by use association, use of that entity is constrained by the
PROTECTED attribute (5.3.15).".
[443:36-37] Replace the first sentence of the second paragraph of
16.5.1.4 Host Association:
"If an entity that is accessed by use association has the same
nongeneric name as a host entity, the host entity is not accessed by
host association by that name."
SUBMITTED BY: Malcolm Cohen
HISTORY: 15-134 m206 F08/0128 submitted
15-134r1 m206 Revised edits - passed by J3 meeting
15-187 m207 Failed J3 letter ballot 15-159
15-208 m207 Revised with 3 options - failed WG5 ballot
16-nnn m209
----------------------------------------------------------------------
More information about the J3
mailing list