To: J3 J3/23-186 From: Malcolm Cohen Subject: Polymorphic outputs from pure Date: 2023-June-13 1. Introduction It would be occasionally useful to be able to invoke, in a context that requires purity or simplicity, a function with a polymorphic result. 2. Discussion The main roadblock is that we cannot know that an impure final subroutine will not get invoked. Is there anything else? Potentially yes, it must not have a coarray component, otherwise there would be synchronisation involved. However, function results are already prohibited from having coarray potential subobject components, so we need not do this unless and until that prohibition is revoked. 3. Proposal That we have some way of designating a type such that it does not have, and any extension of it will not have, a final subroutine that is not pure and/or simple. 4. Illustrative syntax Use the PURE (and SIMPLE?) attributes on the type definition. For example, TYPE,PURE :: mycomplex REAL :: magnitude,angle END TYPE Do we want to have SIMPLE as well as PURE? Then they would be usable in simple procedures too. This does not seem to be astoundingly useful though. Constraints: a type that is PURE (or SIMPLE?) - shall not have a final subroutine that is not PURE (or SIMPLE?); - shall not have a coarray potential subobject component; - shall not have a potential subobject component that has, or might have, an inappropriate final subroutine; - shall not extend a type that has an inapproprate component or final subroutine. Note: The coarray potential subobject component constraints are there so that the constraint against image control statements in pure procedures can be satisfied. Note: This allows for use of "pure" polymorphic local variables in a pure procedure as well as for polymorphic function results. Constraint: - an extension of a PURE (or SIMPLE) type shall be PURE (or SIMPLE). (And this should be explicit, not implicit.) Note: that means that if we have a non-PURE/SIMPLE type t3, we cannot do TYPE,PURE :: badtype CLASS(t3),POINTER :: badcomponent END TYPE ===END===