Print

Print


On Wed, Aug 9, 2017 at 5:11 AM, John Reid <[log in to unmask]> wrote:
> ..
>
> Is the declaration of TOAD:
>
> type(t3(mass_kind=kind(1.0d0),nlen=50,number=3,slen=80 ))::toad(arlen)
>
> legal? ..


@John Reid,

By "legal", do you mean standard conforming?  If not, can you please elaborate?

You included the text from section 7.5.7.2 of the standard and then
you wrote, "only slen is a parameter of the type t3" which would
appear to run counter to the understanding of several including one
compiler implementation as to what the standard text of "An extended
type includes all of the type parameters.. of its parent type. These
are inherited by the extended type from the parent type. They retain
all of the attributes that they had in the parent type." means.  As
stated, it's worrisome to consider the implications of your statement.

So it's unclear what you are trying to convey with your latest note.
Either within the context of code in the original post, or with a
simpler example involving extended parameterized types and a procedure
with a polymorphic dummy argument with the base type, can you
illustrate first what you think is "legal" or standard conforming?  It
will help reconcile the discussion at this stage and avoid any
misunderstandings in any follow-up communication.

For the record, I think the declaration of toad:

type( t3( mass_kind=kind(1.0d0), nlen=50, number=3, slen=80 ) ) :: toad( arlen )

is indeed standard conforming.  I interpret your quoted section
7.5.7.2 from the standard to imply derived type t3 "includes" type
parameters from the base type of t1 (via t2 of course) in a manner
that can be viewed *as if* t3 had the type declaration as follows:

---- begin an illustrating snippet -----
  type :: t3(  mass_kind, nlen, number, slen )
    integer, kind :: mass_kind = kind(1.0)
    integer, len   :: nlen=1, number=1
    integer, len   :: slen
    ...
  end type t3
---- end snippet -----

and this is what makes the declaration of toad to be conforming.

But now paragraph 2 of section 7.5.7.2 in the standard with wordings
such as, "An extended type has a scalar, nonpointer, nonallocatable,
parent component with the type and type parameters of the parent type.
The name of this component is the parent type name." also indicates to
me that the object toad, with it being an instance of an extended type
of t3, includes a component of the base type t1 whose own parameters
of mass_kind and nlen are the same as those conresponding to those
that can be inferred from the above illustration and the listed
declaration.  Meaning the kind parameter mass_kind of the component t1
of toad is of kind(1.0d0) and length parameter nlen is 50..

Thanks much,
Vipul Parekh