(j3.2006) a question on same_type_as and type parameters
Van Snyder
Van.Snyder
Thu Aug 28 14:44:21 EDT 2008
On Thu, 2008-08-28 at 10:09 -0400, Jim Xia wrote:
> The same question also applies to parameterized derived types as can
> be illustrated by the following example
>
>
> type t (k)
> integer, kind :: k
>
> real :: x(k)
> end type
>
> type (t(5)) a
> type (t(10)) b
>
> print *, same_type_as (a, b)
> end
This one would clearly print T, according to the definition of
SAME_TYPE_AS. In this case, one can reference the kind parameters of A
and B without getting at their dynamic types using SELECT TYPE
constructs.
We're stuck with the current definition of SAME_TYPE_AS, unless we're
willing to make an incompatible change that probably wouldn't break any
existing codes.
We could provide a different function to answer SAME_TYPE_AND_KIND_AS,
and another one for length parameters and another one for both.
Alternatively, we could add optional KIND=<logical-expr> and
LEN=<logical-expr> arguments to SAME_TYPE_AS to check equality of KIND
and/or LEN parameters. Maybe the arguments should be
<logical-initialization-expr>.
More information about the J3
mailing list