[J3] surprisingly PURE

Vipul Parekh parekhvs at gmail.com
Tue Apr 21 18:43:12 EDT 2020

On Mon, Apr 20, 2020 at 11:04 PM Van Snyder via J3 <
j3 at mailman.j3-fortran.org> wrote:

> ..
> I don't think this can catch problems related to polymorphism.
> ..
> More hammering is maybe necessary. Maybe prohibiting an <associate-name>
> of such a type to appear in a variable-definition context, if the
> <selector> is not a dummy argument or subobject thereof, is enough. ..

Hi Van,

I'm not sure I understand the points you make.  Please note in section
19.6.7 Variable definition context, the standard states in paragraph 1,
bullet 11, page 516, "a variable that is a selector in an ASSOCIATE, CHANGE
TEAM, SELECT RANK, or SELECT TYPE construct if the corresponding associate
name or any subobject thereof appears in a variable definition context"

Given the description of the variable context, the instruction you show
with "Y%P = 42.0" in your example with the polymorphic case will be
disallowed per my simple-minded suggestion of a constraint.  Or are you
concerned with preciseness of the wording in that it does not clarify
whether it is the declared or the dynamic type and in what context?  If so,
would the following help?

C1589a A local variable of a pure subprogram, or of a BLOCK construct
within a pure subprogram, shall not be used in a variable-definition
context (19.6.7) if the *dynamic type* of the variable in the
variable-definition context is a derived type where the type has a
default-initialized ultimate component at any level of component selection
that is a data pointer component and such a data pointer component has an
initial-data-target that is not a local variable of the subprogram.

Vipul Parekh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20200421/909a2cf8/attachment-0001.htm>

More information about the J3 mailing list