From jkr@jkr.cc.rl.ac.uk  Mon May 14 14:59:25 2001
Received: from nameserv.rl.ac.uk (nameserv.rl.ac.uk [130.246.135.129])
	by dkuug.dk (8.9.2/8.9.2) with ESMTP id OAA39774
	for <SC22WG5@dkuug.dk>; Mon, 14 May 2001 14:59:16 +0200 (CEST)
	(envelope-from jkr@jkr.cc.rl.ac.uk)
Received: from jkr.cc.rl.ac.uk (jkr.cc.rl.ac.uk [130.246.8.20])
	by nameserv.rl.ac.uk (8.8.8/8.8.8) with ESMTP id NAA02604
	for <SC22WG5@dkuug.dk>; Mon, 14 May 2001 13:59:29 +0100
Received: (from jkr@localhost)
	by jkr.cc.rl.ac.uk (8.8.8+Sun/8.8.8) id OAA13088
	for SC22WG5@dkuug.dk; Mon, 14 May 2001 14:01:37 +0100 (BST)
Date: Mon, 14 May 2001 14:01:37 +0100 (BST)
From: John Reid <jkr@rl.ac.uk>
Message-Id: <200105141301.OAA13088@jkr.cc.rl.ac.uk>
To: SC22WG5@dkuug.dk
Subject: Interp F90/191
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"


WG5,
    Here is a draft response for interp. F90/191. Comments,
please, preferably to me in private, before I send this to J3.

John Reid. 


                                                       J3/01-xxx

Date:    2 May 2001
To:      J3
From:    John Reid
Subject: Interpretation F90/000191 (Interaction of SEQUENCE derived
         types and rename)

Here is a new draft response. I append the present draft and the
comments on it that were made with the J3 ballot in 1995. I have
based this draft reply on the suggestion that I made in my 1995
ballot comment. 

NUMBER: F90/000191
TITLE: Interaction of SEQUENCE derived types and rename
KEYWORDS: SEQUENCE, derived type, use association, derived type
DEFECT TYPE: Interpretation
STATUS: J3 consideration in progress

QUESTION:  Consider the following:

   MODULE M
     TYPE T
       SEQUENCE
       TYPE (T), POINTER :: P
     END TYPE
   END MODULE

   USE M, T2=>T
   TYPE T
    SEQUENCE
       TYPE (T2), POINTER :: P
   END TYPE
   TYPE (T) X
   TYPE (T2) Y
   X = Y
   END

Section 4.4.2, 'Determination of derived types', seems to indicate that types T
and T2 in the main program refer to the same type.  Note that both types have
structure components that agree in order, name, and attributes.  However,
considering type T in the context of module M only, type T is a derived type
that contains one component that is a pointer to itself.  In the context of the
main program, type T is a derived type that contains one component that is a
pointer to a different derived type.

Are types T and T2 considered to be the same type?

ANSWER:  Yes, T and T2 are the same type.   

DISCUSSION: By the use of rename, it is possible for a scoping unit to
have access by different local names to two separate derived-type
definitions that have the same original name. Section 4.4.2 says:
'Data entities in different scoping units also have the same type if
they are declared with reference to different derived-type definitions
that have the same name,... '. This wording makes clear that it is the
name of the derived-type definition (the original name) that is crucial
when deciding whether two types are the same, rather than the local
name of the type. This is confirmed in NOTE 4.32.

EDITS: None.
 
SUBMITTED BY: Janice C. Shepherd
HISTORY: 94-273   m130 submitted
         94-377   m131 Response submitted, approved  u.c.
         95-034r1 m132 X3J3 ballot failed 15-5

-----------------------------------------------------------------------------

Old answer

ANSWER:  Yes, T and T2 are the same type.  An edit is provided to clarify this
conclusion.

Discussion: The first sentence in section 4.4.2 states, "a particular type name
may be defined at once in a scoping unit." However, by the use of rename, it's
possible for a scoping to have access to two separately defined derived types,
that were originally defined the same name, by two different local names.  For
derived types made accessible by use association, the derived type name referred
to in section 4.4.2 is <type-name> in the corresponding <derived-type-stmt>.
Edits are provided to clarify this.

EDITS:
1.  In section 4.4.2, add the following to the end of the first paragraph:
    [35:39]

     "In addition, two derived types accessible in the same scope might be the
      same if one or both are accessible by use association."

2.  In section 4.4.2, after the second paragraph, add the following independent
    paragraph: [35:46]

     "Note that the criterion that the two types have the same name applies
     to the <type-name> of the respective <derived-type-stmt>."

-------------------------------------------------------------------------------

Ballot comments

   000191 Interaction of SEQUENCE derived types and rename
        Vote =  15 (6) - 5

   191 N Adams  I feel strongly that no edits to the document are needed.
        An answer is all that is required.  The edit to section
        4.4.2 contributes to any confusion over naming and rename
        for derived types.

   191  Y  Barber  In the second edit I find use of "respective"
               in a singular context unusual.  This reads better if you
               change <type-name> to <type-name>s and
               <derived-type-stmt> to <derived-type-stmt>s.  I realise
               using plural versions of syntactic class names is also
               awkward but I can't think of a better wording right now.

   191 Y Bierman  The first sentence of DISCUSSION is missing a
           word. Most I think. Also missing the word unit (as in
           scoping unit).

           I suspect that other changes will be proposed by others.  I
           hope so, as it's pretty unreadable (to someone not hip to the
           subgroup meeting/discussions) otherwise.

   191 N  Dedo  I agree with John Reid.

   191 Y Hirchert I am voting yet because I believe the answer to be correct.
              I find it difficult to dispute John Reid's claim that the
              edits are unnecessary, since both appear to be notes, but
              I'm not certain that this means that they should not be made.

   191 Y   Levine
        Reid raises some valid concerns.  The case is fairly complex,
        however, and the additional "note that" comments seems to
        enhance the comprehensibility.

   191 N Maine  Agree with John Reid's comments.  I hadn't noticed interp 20
             when voting on this at the meeting.


   191  N  martin    The edits are not needed, and worse, are confusing.  I
             recommend this item be subsumed by item 20.  There are
             several problems in the Discussion (words and letters
             missing), but if it is going away, it is not worth fixing.
             If, instead, John Reid's answer is substituted, I believe
             "scoping" (in the first line of Discussion) should be
             "scoping unit", and in the second paragraph,
             "interpretation", should be "defect item".


   191 N North   See comments by J. Shepherd and R. Maine.

   191 N  Reid
      No edits are needed in response to this interpretation. This question
      is very close to that raised in 006/020 and no edits were deemed
      necessary then. The first edit will confuse the reader of paragraph 1,
      which is correct as it stands.  The second edit is unnecessary because
      the wording in lines 41-43 is 'Data entities in different scoping units
      also have the same type if they are declared with reference to
      different derived-type definitions that have the same name,... ' This
      wording already makes clear that it is the name of the derived-type
      definition that is crucial, not the local name of the type. Here is an
      alternative answer:

      ANSWER:  Yes, T and T2 are the same type.

      DISCUSSION:
      By the use of rename, it is possible for a scoping to have access by
      different local names to two separate derived-type definitions that
      have the same original name. Section 4.4.2 says:  'Data entities in
      different scoping units also have the same type if they are declared
      with reference to different derived-type definitions that have the same
      name,... '. This wording makes clear that it is the name of the
      derived-type definition (the original name) that is crucial when
      deciding whether two types are the same, rather than the local name of
      the type.

      See, also, the discussion in interpretation 020.

      REFERENCE: ISO/IEC 1539:1991, section 4.4.2.

      EDITS: None.

   191 Y Rolison  The quote in the first sentence of DISCUSSION is missing the
            word "most".  It should read "may be defined at most once".

            "a scoping to" should be "a scoping unit to".

            What should "originally defined the same name" really say?
            "originally defined with the same name"?

            "us association" should (I think) be "use association".  :-)

            What does "in the corresponding <derived-type-stmt>" refer
            to?  The <derived-type-stmt> in the module?

            I don't think the first edit is going to help anyone that
            has not studied this interpretation question.  How about a
            little clue, like:

              "In addition, two SEQUENCE derived types accessible
               in the same scope might be the same if one or both are
               accessible by use association and at least one of them
               is renamed."

            The edit only applies to SEQUENCE derived types, right?  If
            they are not SEQUENCE derived types, but they have the same
            name, they are by definition the same type, are they not?  So
            then we couldn't possibly have "two" nonsequence derived
            types, could we?  Or is this somehow trying to apply to:

                  MODULE m1
                    TYPE t
                      INTEGER i
                    END TYPE
                  END MODULE

                  MODULE m2
                    TYPE t
                      INTEGER i
                    END TYPE
                  END MODULE

                  PROGRAM test
                    USE m1
                    USE m2
                    TYPE(t) s
                    ...
                  END

             And how would the original new edit and my suggested edit
             be extended to more than two types that are the same?

             The second edit appears to be completely content-free.  What
             on earth does it mean?  The sentence has plural "types" but
             singular "<derived-type-stmt>".

   191 Y Shepherd
     - In the question change "one one" to "one"

   ------------------------------------------------------------------

