[J3] another PURE example

Vipul Parekh parekhvs at gmail.com
Tue Oct 6 01:37:48 EDT 2020


On Mon, Oct 5, 2020 at 6:13 PM Robert Corbett via J3 <
j3 at mailman.j3-fortran.org> wrote:

>
>       PURE SUBROUTINE SUBR
>       USE T1
>       USE T2, TINIT => T
>         TYPE(T) Y
>         Y = TINIT()
>         Y%P = 2.0
>       END
>


Hi Bob.

At first glance, your assignment instruction 'Y = TINIT()' looks
non-conforming to me.

I am thinking derived types are local identifiers and thus 'TINIT' is a
different type than 'T'.  Since there is no defined assignment, the TKR
rules for intrinsic assignment aren't being followed with the 'Y = TINIT()'
assignment.  Now, if you implement a defined assignment, you won't be able
to make it a PURE procedure and yet shallow/deep copy the POINTER
component.  And without a PURE defined assignment, you won't be able to do
what you are doing in your 'SUBR' procedure.  Thus the semantics of PURE
looks Ok as captured in the standard?

Some food for thought?
Vipul Parekh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201006/28208d2f/attachment-0001.htm>


More information about the J3 mailing list