From JANSHEP@torolab2.vnet.ibm.com Wed Feb 23 10:14:57 1994
Received: from vnet.ibm.com by dkuug.dk with SMTP id AA28297
  (5.65c8/IDA-1.4.4j for <sc22wg5@dkuug.dk>); Wed, 23 Feb 1994 21:19:55 +0100
Message-Id: <199402232019.AA28297@dkuug.dk>
Received: from TOROLAB2 by vnet.IBM.COM (IBM VM SMTP V2R2) with BSMTP id 7574;
   Wed, 23 Feb 94 15:13:54 EST
Date: Wed, 23 Feb 94 15:14:57 EST
From: "Janice Shepherd" <JANSHEP@torolab2.vnet.ibm.com>
To: sc22wg5@dkuug.dk
Subject: array constructors in initialization expressions
X-Charset: ASCII
X-Char-Esc: 29

I'd like to have a discussion about interpretation 129. I've included
the text of interpretation 129 at the bottom of this note.

Interpretation 129 indicates that examples such as
       INTEGER ARRAY(3)
       PARAMETER ( ARRAY = (/ (ABS(I), I=1,3) /) )
are not valid as they don't meet the requirements for initialization
expressions (see the interpretation for the reasoning).

We have observed of late that the example
       INTEGER ARRAY(3)
       PARAMETER (ARRAY = (/ (ABS( (/ I /)), I= 1,3) /) )
would be valid.
Rule 4 in 7.1.6.1 indicates that the argument to an elemental
intrinsic must be an initialization expression, rule 2 indicates
that (/ I /) is an initialization expression as it is an array
constructor and I is an implied-Do variable.
It thus, seems odd to have the language permit the more
complicated expression ABS((/ I /)) but not allow ABS(I).

We are wondering if interpretation 129 should instead be
applying an edit to allow the first example as listed above.

A similar inconsistency is that
     INTEGER A(3), B(2)
     PARAMETER (A=(/1,2,3/))
     PARAMETER (B = (/ (A(I),I=1,2) /) )
is not allowed  (rule 1 indicates that a constant subobject must
have a subscript that is an initialization expression and 'I'
by itself is not an initialization expression) but that the
following example is allowed:
     INTEGER A(3), B(2)
     PARAMETER (A=(/1,2,3/))
     PARAMETER (B = (/ (A( (/I/) ),I=1,2) /) )

Opinions?
Thanks.
Janice C. Shepherd


 NUMBER: 000129
 TITLE: Array constructors in initialization expressions
 KEYWORDS: array constructor, expression - initialization, implied-DO variable
 DEFECT TYPE: Interpretation
 STATUS: X3J3 approved; ready for WG5

 QUESTION:  It was likely the intent of the standard to allow the program
 fragment

             INTEGER ARRAY(3)
             PARAMETER ( ARRAY = (/ (ABS(I), I=-3,-1) /) )

 However, according to the text in the second list in 7.1.6.1

     "(/ (ABS(I), I=-3,-1) /)"

 is not an initialization expression.

 The array constructor

     "(/ ABS(-3), ABS(-2), ABS(-1) /)"

 qualifies as an initialization expression since item (2) in the list indicates
 that an array constructor is an initialization expression if each element is an
 initialization expression, and (4) includes

       "An elemental intrinsic function reference of type integer or
        character where each argument is an initialization expression of
        type integer or character"

 The problem with the "ABS(I)" in

     PARAMETER ( ARRAY = (/ (ABS(I), I=-3,- 1) /) )

 is that "ABS(I)" is not defined as an initialization expression.  It does not
 qualify under (4) as "I" is not an initialization expression and it does not
 qualify under (2) as the primary ABS(I) is neither an initialization expression
 nor an implied-DO variable.

 Is the program fragment standard conforming?

 ANSWER: No, the fragment is not standard conforming.

         In the fragment

             PARAMETER (ARRAY = (/ (ABS(I), I = -3, -1) /) )

         and considering 7.1.6.1, second list, rule 2

             ABS(I) is an element of the array constructor.  It is an expression
             consisting of exactly one primary, a function reference.

             That function reference has one argument, I, which is another
             expression consisting of exactly one primary. That primary is not
             an initialization expression and thus does not meet the requirements
             of rule 4.

 Nothing could be found indicating that the intent of standard was other than
 that indicated above.

 REFERENCES: ISO/IEC 1539:1991 (E) section 7.1.6.1
 EDITS:  None.
 SUBMITTED BY: Janice C. Shepherd
 HISTORY: Submitted as paper 93-027
          Draft response 93-088 approved
          93-111 m125 ballot approved with Martin, Rolison edits
