[J3] another PURE example

Steidel, Jon L jon.l.steidel at intel.com
Tue Oct 6 12:50:28 EDT 2020


Hi Vipul,

Pointer is absolutely an attribute in Fortran.  Pointers are described in section 8.5.14 POINTER attribute.

I believe Malcolm’s point was that initialization does not play a role in determination of derived type.  In you second example, I believe the two types are the same, even though they have different default initialization values.

-jon

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Vipul Parekh via J3
Sent: Tuesday, October 6, 2020 12:24 PM
To: Malcolm Cohen <malcolm at nag-j.co.jp>
Cc: Vipul Parekh <parekhvs at gmail.com>; General J3 interest list <j3 at mailman.j3-fortran.org>
Subject: Re: [J3] another PURE example


On Tue, Oct 6, 2020 at 3:00 AM Malcolm Cohen <malcolm at nag-j.co.jp<mailto:malcolm at nag-j.co.jp>> wrote:

>I am thinking derived types are local identifiers and thus 'TINIT' is a different type than 'T'.

1.      Derived types are not identifiers.
2.      Whether you have a rename or not, there is a local identifier for a local entity that is use-associated with the module entity.
3.      The rules for whether two types are “the same type” are spelled out in clause 7, in particular, in 7.5.2.4 Determination of derived types. This is non-trivial for SEQUENCE types.
4.      At first glance, Robert’s two type definitions appear to satisfy the requirements for the two type definitions to be the same.

Hi Malcolm,

Thanks for pointing out section 7.5.2.4 Determination of derived types.  That helps.

A couple of simple clarification questions wrt Bob's example, if you don't mind:

1) Given the standard states, "Data entities also have the same type if they are declared with reference to different derived-type definitions ..and have components that agree in order, name, and attributes, " firstly, would you agree POINTER is an attribute?  And which would mean (obviously!) that type 't' in the 2 modules below refer to different types?

module a
   type :: t
      sequence
      integer :: n
     end type
end module a

and

module b
   type :: t
      sequence
      integer, pointer :: n
     end type
end module b

2) But that your point is that because component initialization is not mentioned in section 7.5.2.4, the presence or absence of it is not relevant to the determination of different types?  Can you confirm?  That is, in the example below, you think the 2 types are the same?

module a
   type :: t
      sequence
      integer, pointer :: n
     end type
end module a

and

module b
   type :: t
      sequence
      integer, pointer :: n => foo ! please assume 'foo' is a valid target here
     end type
end module b

Thanks,
Vipul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201006/95e7bc72/attachment-0001.htm>


More information about the J3 mailing list