John Reid wonders:
>Is the declaration of TOAD:
>
>type(t3(mass_kind=kind(1.0d0),nlen=50,number=3,slen=80 ))::toad(arlen)
>
>legal?
Yes.
> 7.5.7.2 says
>"An extended type includes all of the type parameters, all of the
components, and the nonoverridden (7.5.7.3) type-bound procedures 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.
Additional type parameters, components, and procedure bindings may be
declared in the derived-type definition of the extended type."
>
>I think only slen is a parameter of the type t3.
The very text you quoted contradicts this assertion. An extended type
*includes all of the type parameters*
of its parent type. So t1 (the base type) has three type parameters,
MASS_KIND, NLEN and NUMBER; t2 declares no additional type parameters, so it
has the three type parameters it inherited from its parent type: MASS_KIND,
NLEN and NUMBER; and t3 adds a new type parameter SLEN so with the three
type parameters inherited from its parent type, has four type parameters.
Not to mention that your conjecture would mean you cannot extend a type with
type parameters, consider:
TYPE t(k)
INTEGER,KIND::k
REAL(k) c
END TYPE
TYPE,EXTENDS(t) :: t2
END TYPE
With your conjecture, T2 would have no type parameters, and yet it has a
component C which depends on the type parameter K. This cannot possibly
make sense. Fortunately, the standard unambiguously denies your conjecture.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
|