(j3.2006) Is really necessary?

Van Snyder Van.Snyder
Fri May 6 20:10:43 EDT 2016

A colleague tried to write a simple routine that would compute the size
in bytes of an array (to track memory usage), deallocate it, test the
status, and print a message if failure occurred.  Rather than writing
one for every type and kind, he tried to make the dummy argument
unlimited polymorphic.

This fell afoul of

        The actual argument shall be polymorphic if and only if the
        associated dummy argument is polymorphic, and either both the
        actual and dummy arguments shall be unlimited polymorphic, or
        the declared type of the actual argument shall be the same as
        the declared type of the dummy argument.

Is this paragraph really necessary?  It seems that the object-oriented
system ought to work just fine without it, albeit with some more words
to describe how a dummy argument can be allocated if the actual
argument's declared type is compatible with but not necessarily
identical to the dummy argument's declared type.  The result would of
necessity be that the dynamic type of the allocated entity is type
compatible with the declared type of the actual argument if the actual
argument is polymorphic, and the same type if it's not.  If there is no
type spec in the allocate statement, the allocated type is the declared
type of the actual argument.    Everything else, including deallocation,
ought to work without additional explanation.

Processors might endure some complication in creating descriptors to
connect polymorphic dummy arguments to nonpolymorphic actual arguments,
or actual arguments whose declared types are type compatible rather than
identical.  The "type" member of the CFI_cdesc_t struct ought to serve
for this purpose.  Because having a polymorphic dummy argument requires
an explicit interface, a processor would know where this is required.

More information about the J3 mailing list