(j3.2006) Problem with default expressions for kind type parameters?
Van Snyder
Van.Snyder
Fri Sep 21 16:37:29 EDT 2012
On Fri, 2012-09-21 at 08:04 -0500, Bill Long wrote:
>
> 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 "=".
Yeah, the problem is in the <type-param-decl>, not in the
<derived-type-stmt>.
> > 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.
Malcolm has suggested "previously declared." Right now, there is no
constraint on the <scalar-int-constant-expr> in <type-param-decl>.
> 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
> >
>
More information about the J3
mailing list