(j3.2006) Is 7.2.1.2p1(1) necessary?

Van Snyder Van.Snyder
Wed Mar 11 21:51:01 EDT 2015


7.2.1.2p1(1) says "if the variable is polymorphic it shall be
allocatable and not a coarray."

This makes it impossible to assign to an element or section of a
polymorphic array without a SELECT TYPE construct.  Indeed, two nested
SELECT TYPE constructs are needed, to avoid violating 7.2.1.2p1(4).

    if ( .not. SAME_TYPE_AS ( v, e ) ) &
      & call Stop_With_Error_Message ( "Wrong Types" )
    SELECT TYPE ( v )
    TYPE IS ( <whatever> )
      SELECT TYPE ( e )
      TYPE IS ( <same whatever> )
        v(i) = e
      END SELECT
    END SELECT

As Tom mentioned, this would be easier if SELECT TYPE could have more
than one selector:

    SELECT TYPE ( v, e )
    TYPE IS ( <whatever>, <same whatever> )
      v(i) = e
    END SELECT

Bit is it really necessary for it to be allocatable?  Would it be enough
to require that if it is not allocatable, variable and expr shall have
the same dynamic type?

For polymorphic assignment, as it stands now, processors have to check
the dynamic type anyway, either to allocate the variable with that type,
or at least to determine whether the dynamic types are the same if they
want to bypass re-allocating the variable in that case.  So checking the
dynamic types, and raising an error condition if they're different,
isn't any more difficult that what's required now.






More information about the J3 mailing list