(j3.2006) Problem with default expressions for kind type parameters?

Bill Long longb
Fri Sep 21 09:04:14 EDT 2012



On 9/20/12 10:17 PM, Van Snyder wrote:
> A type parameter name in a type definition is a valid primary in a
> constant expression (7.1.12p1(9)).
>
> One need not specify kind type parameter values in the declarations of
> objects of a type if there is a default in the type definition.
>
> There appears to be a problem with this:
>
>    type :: T(J=k+1,K=j+1)

I agree there is a problem with this statement.  The syntax for the part 
enclosed by the ( ) following the type name is a <type-param-name-list> 
in R426.   k+1 is not a "name".  Neither is something involving an "=".

>      integer, kind :: J, K
>    end type T
>
>    type(t) :: V
>
> Do we need a constraint something like this?
>
> C438a (R431) There shall not be a circular dependence between a
>        <scalar-int-constant-expr> in a <type-param-decl> and any
>        <type-param-name> in the same <type-param-decl-list>.

It appears that you are trying to prevent

   integer,kind :: j=K+1,  K=j+1

which would be a problem.

Cheers,
Bill

>
> A bigger hammer, perhaps larger than necessary, is
>
> C438a (R431) A <type-param-name> shall not appear in a
>        <scalar-int-constant-expr> in the same <type-param-decl-list>.
>
> A medium-size hammer, easier to check than the first one, is
>
> C438a (R431) A <type-param-name> that appears in a
>        <scalar-int-constant-expr> in a <type-param-decl-list> shall
>        be declared earlier in that <type-param-decl-list>.
>
> I think this is the tiniest hammer that works (maybe):
>
> C485a (R453) If there is a circular dependence between a
>        <scalar-int-constant-expr> in a <type-param-decl> and any
>        <type-param-name> in the same <type-param-decl-list>, a
>        <type-param-value> shall be provided for at least one of
>        the <type-param-name>s in the circular dependency relationship.
>
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
>

-- 
Bill Long                                           longb at cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101





More information about the J3 mailing list