[J3] Question on parent component naming
Malcolm Cohen
malcolm at nag-j.co.jp
Mon Apr 8 23:50:18 UTC 2024
I do not think so.
Renaming does not change the name of the components. It just adds a local
name for the remote name.
I can't believe anyone thinks it is a good idea to go around renaming
components. Well, okay, I can believe it, but I cannot understand it.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of John Reid via J3
Sent: Tuesday, April 9, 2024 12:51 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: John Reid <john.reid9 at talktalk.net>
Subject: Re: [J3] Question on parent component naming
Reinhold,
I believe that your program is standard-conforming. 14.2.2, para 7 says
An accessible entity in the referenced module is associated with one or more
accessed entities, each with its own identifier. These identifiers are
the identifier of the entity in the referenced module if that identifier
appears as an only-use-name or as the defined-operator of a generic-spec in
any only for that module, each of the local-names or
local-defined-operators that the entity is given in any rename for that
module, and the identifier of the entity in the referenced module if that
identifier does not appear as a use-name or use-defined-operator in any
rename for that module.
This is saying that rename really does renaming. The entity is known by its
new name and is not known by its original name. So your code behaves like
this code
PROGRAM ref_parent
TYPE :: my_t
REAL, POINTER :: p(:) => null()
END TYPE
TYPE, EXTENDS(my_t) :: td
REAL :: data(3)
END TYPE
TYPE(td), TARGET :: o_my_t
o_my_t%my_t = my_t(o_my_t%data) ! (x)
! o_my_t%t = my_t(o_my_t%data) ! (y)
END PROGRAM
which looks good to me, but not if you replace (x) by (y).
I think NOTE 1 in 7.5.7.1 is just doing what notes do - clarifying what has
already been defined normatively.
Cheers,
John.
Bader, Reinhold via J3 wrote:
>
> Dear J3,
>
> consider the following program:
>
> MODULE mod
>
> TYPE :: t
>
> REAL, POINTER :: p(:) => null()
>
> END TYPE
>
> END MODULE
>
> PROGRAM ref_parent
>
> USE mod, my_t => t
>
> TYPE, EXTENDS(my_t) :: td
>
> REAL :: data(3)
>
> END TYPE
>
> TYPE(td), TARGET :: o_my_t
>
> o_my_t%my_t = my_t(o_my_t%data) ! (x)
>
> ! o_my_t%t = my_t(o_my_t%data) ! (y)
>
> END PROGRAM
>
> Two compilers accept this code. Two other compilers tell me that my_t
> is not a parent component of o_my_t, at (x)
>
> One of those two others accepts the variant statement (y), the other
> one crashes when (y) is used.
>
> I tend to believe that the above is conforming, but this is based on
> non-normative evidence (NOTE 1 in 7.5.7.1 of 24-007).
>
> Any opinions?
>
> Regards
>
> Reinhold
>
More information about the J3
mailing list