From owner-sc22wg5@dkuug.dk  Fri Jul 25 12:33:52 2003
Received: (from majordom@localhost)
	by dkuug.dk (8.12.8p1/8.9.2) id h6PAXq1V026848
	for sc22wg5-domo; Fri, 25 Jul 2003 12:33:52 +0200 (CEST)
	(envelope-from owner-sc22wg5@dkuug.dk)
X-Authentication-Warning: ptah.dkuug.dk: majordom set sender to owner-sc22wg5@dkuug.dk using -f
Received: from inf.rl.ac.uk (nfs7.inf.rl.ac.uk [130.246.72.7])
	by dkuug.dk (8.12.8p1/8.9.2) with ESMTP id h6PAXhEc026843
	for <sc22wg5@dkuug.dk>; Fri, 25 Jul 2003 12:33:47 +0200 (CEST)
	(envelope-from j.k.reid@rl.ac.uk)
Received: from numerical.cc.rl.ac.uk (numerical [130.246.8.23])
	by inf.rl.ac.uk (8.11.6+Sun/8.8.8) with ESMTP id h6PAVOD03136
	for <sc22wg5@dkuug.dk>; Fri, 25 Jul 2003 11:31:24 +0100 (BST)
Received: from rl.ac.uk (jkr.cse.rl.ac.uk [130.246.9.202])
	by numerical.cc.rl.ac.uk (8.8.8+Sun/8.8.8) with ESMTP id LAA04289
	for <sc22wg5@dkuug.dk>; Fri, 25 Jul 2003 11:42:37 +0100 (BST)
Message-ID: <3F210958.7000900@rl.ac.uk>
Date: Fri, 25 Jul 2003 11:41:28 +0100
From: John Reid <j.k.reid@rl.ac.uk>
Reply-To: j.k.reid@rl.ac.uk
Organization: Rutherford Appleton Laboratory
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: WG5 <sc22wg5@dkuug.dk>
Subject: N1545
Content-Type: multipart/mixed;
 boundary="------------080609030508000007000801"
Sender: owner-sc22wg5@dkuug.dk
Precedence: bulk

This is a multi-part message in MIME format.
--------------080609030508000007000801
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Here is a paper that I intend to be on the server later today.

Cheers,

John.

--------------080609030508000007000801
Content-Type: text/plain;
 name="N1545.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="N1545.txt"

                                       ISO/IEC JTC1/SC22/WG5 N1545

	             Local/global entities

                          Richard Maine

This is a very minor revision of N1525 based on comments.  All of
the revisions to edits are on the level of typos or minor wording
changes.

This material was submitted as J3/03-160 for J3 meeting 164.
However, it got overlooked and was not processed at that meeting.
The edits have been updated to refer to line numbers and sections
of J3/03-007.

Item T5 in section 2.12 of 03-107r1 advocates fixing confusions
and errors relating to the terms "local entity", "local name",
"global entity", and "global name".

For example, section 16.1.0 talks about "a name that identifies a
global entity" in a way that apparently forgets that global
entities may be identified by local names (via rename).
(surprised there hasn't been an interp on that one because it
sure sounds like it is saying that a widespread practice is
illegal).

Analysis

  The term "local variable" was introduced in 01-163; it cleared up
  several related confusions, but others remain.

  The term "local identifier" is used only in 11.2.1.  It seems
  adequately defined, if somewhat narrow.  In current use, it
  refers only to USE statements.  If necessary, we could broaden
  it (as this paper proposes).

  Local-name is a bnf term in c11.  This is used to imply a
  definition of the textual term "local name", which appears 6
  times, none of them in normative text.  As with "local
  identifier", the definition seems adequate, though restricted to
  USE statements.

  The term "global name" appears 7 times, none of which define it, and
    only 1 of which is in normative text.

    Annex C - 1 in c.8.1, 2 in c.9.2)
    C16 - 3 in Note 16.2, 1 in 16.4.1.3.

  The term "global entity" appears 16 times, once in its glossary
  definition, one in 12.1.2.2, and 14 in c16.  Throughout, we
  hopelessly confuse the identifiers and the entities themselves.
  This is more then just editorial nit-picking; it results in
  statements that are certainly not what we intended to say.  For
  example, c16.1 says that a name that identifies a global entity
  may not be used to identify a different global entity in the
  same program.  This appears to forget completely about the fact
  that renaming with USE allows us to use local names to identify
  global entities; this is a mess.

  The term "local entity" appears 30 times, two in the glossary,
  one in 2.4.3.1.1, one in 12.1.2.4, and 26 in c16.  As with
  "global entity", the usage seems very confused about the entity
  vs its name.

  Thus we see that the problem terms are "local entity" and
  "global" entity, and that the problem is largely restricted
  to c16.

  The terms "construct entity" and "statement entity" are also
  used, but they are less problematic because the scope of their
  identifiers is always the same as the scope where the entity
  itself might be said to "live".  Those terms also aren't used
  very many times, so it wouldn't be difficult to revise them if
  necessary, but I propose to leave them alone, partly because
  the obvious terms "statement identifier" and "construct identifier"
  sound like identifiers of statements or constructs instead of
  identifiers with those scopes.

  In the large majority of the cases where the terms "local entity"
  or "global entity" appear, we are really talking about local
  identifiers or global identifiers.  It is the identifiers, not
  the entities that have scope.  That's what the first sentence of
  c16 pretty explicitly says.  We have very little use for the
  concept of scope of an entity (as opposed to its identifier).

  I propose that we rid the draft of most reference to scope of
  global and local entities; instead referring to the scope of
  identifiers.  I'll explicitly call out the few exceptions that
  seem merited.  An awful lot of the instances of "local/global
  entity" already read something like "name that identifies a
  local/global" entity already; these are easy to change the
  simpler "local/global name", with the extra advantage that it is
  more likely to be correct (in the case of a local name of a
  global entity).


Edits in c16 (the big part)

  [407:4-5] "entity" -> "identifier" (4 times).

  [407:17] "entities" -> "identifiers"

  {It seems convenient to leave the definition of a global entity,
  but to distinguish it from the definition of a global identifier.
  This will allow us to refer to a local identifier of a global
  entity.  There may be multiple names "used to identify" a global
  entity, but only one of them is the name "of" the entity; that is
  the only global one.}

  [407:19] "A name that identifies" -> "The name of"

  [407:20] Add a comma before "or".  (Unrelated editorial fix).

  [407:20] "shall" -> "is a global identifier and shall"

  [407:20] "used to identify" -> "the same as the name of"

  [407:22] "that identifies" -> "of"

  [407:22] "shall" -> "is a global identifier and shall"

  [407:22] "used to identify" -> "the same as the binding label of"

  [407:23] "used to identify" -> "of"

  {The following paragraph is the result of applying the above
   edits to the first para of 16.1.}

    "Program units, common blocks, external procedures, procedure
     binding labels, and variables that have the BIND attribute
     are global entities of a program.  The name of a program
     unit, common block, or external procedure is a global
     identifier and shall not be the same as the name of any
     other such global entity in the same program, except that an
     intrinsic module and a nonintrinsic module may have the same
     name in the same program.  A binding label of a global
     entity of the program is a global identifier and shall not
     be the same as the binding label of any other global entity
     of the program; nor shall it be the same as a name of any
     other global entity of the program, ignoring differences in
     case."

  {We have now defined "global identifier".  I think that, along
  with [407:8-9], which says that a name is a form of identifier,
  is sufficient definition for the non-normative uses of the term
  "global name".  We'll fix the one normative use below.}

  [408:2] "entities" -> "identifiers"

  [408:3] "entities" -> "identifiers of entities"

  {The next 3 edits avoid refering to "identifiers of names";
  this also fixes the apparent omission of defined operators,
  because they do have generic interfaces, but not generic names.}

  [408:6] "generic names" -> "generic interfaces"

  [408:7] "group names" -> "groups"

  [408:8] "binding names" -> "bindings"

  [408:10] "entities of" -> "identifiers in"

  [408:7] Before the comma, insert
     ", external procedures accessed via USE"

  [408:12] "name that identifies a global entity" ->
     "global identifier used"

  [408:13] "used to identify a local entity" ->
     "the same as a local identifier"

  [408:14] "an identifier of a local entity" -> "a local identifier"

  [408:14-15] "used to identify another local entity" ->
     "the same as another local identifier"

  [408:16-17] "name that identifies a local entity" ->
       "local identifier"

  [408:17] "used to identify a local entity" ->
       "the same as a local identifier"

  {The following is the result of applying the above
   edits to the first 3 paras of 16.2.}

    "16.2 Scope of local identifiers

     Within a scoping unit, identifiers of entities in the
     following classes:

       (1) Named variables that are not statement or construct
       entities (16.3), named constants, named constructs,
       \obs{statement functions,} internal procedures, module
       procedures, dummy procedures, intrinsic procedures,
       abstract interfaces, generic interfaces, derived types,
       namelist groups, external procedures accessed via USE,
       and statement labels,

       (2) Type parameters, components, and bindings, in a
       separate class for each type, and

       (3) Argument keywords, in a separate class for each
       procedure with an explicit interface

     are local identifiers in that scoping unit.

     Except for a common block name (16.2.1), an external
     procedure name that is also a generic name, or an external
     function name within its defining subprogram (16.2.2), a
     global identifier used in a scoping unit shall not be the
     same as a local identifier of class (1) in that scoping
     unit.

     Within a scoping unit, a local identifier of one class shall
     not be the same as another local identifier of the same
     class, except that a generic name may be the same as the
     name of a procedure as explained in 12.3.2.1 or the same as
     the name of a derived type (4.5.9).  A local identifier of
     one class may be the same as a local identifier of another
     class."

  {In addition to the other change, we might as well just say
  "class 1" instead of "the same class".}

  [408:Note 16.3 lines 1-2] "containing another local entity of the
     same class and having the same name" -> "that uses the same
     name as a local identifier of class 1 for a different entity"

  [408:18] "The name of a local entity" -> "A local identifier"

  [409:5] "entities that have the same names as common blocks" ->
      "identifiers that are the same as common block names"

  [409:7] "If ... ," ->
     "If a local identifier is also the name of a common block,"

  [409:9] "identifies only the local entity" ->
     "is an appearance of the local identifier"

  [411:25-26,33-34]
     "name that identifies a global entity or [a] local entity"
     -> "global identifier or a local identifier"  (twice)

  [411:26,34] Delete "accessible" (twice)

  [411:29,37] [412:3]  "the name of a global or local entity"
     -> "a global or local identifier"  (3 times)

  [411:32,40] [412:6] "that of the global or local entity"
     -> "the global or local identifier" (3 times)

  {It seems to me that 412:30-35 neglects host association of
   entities that have identifiers other than names, but that is
   not the subject of this paper, and I have enough else to
   cover, so I'll pass over it.}

  {We could probably manage without the following edit; the original
  was correct, but this was the only normative use of "global name",
  so I thought it better to change it to the same term as we
  explicitly define and use elsewhere.}

  [413:4] "global name" -> "global identifier"

  {Fix a long-standing, run-on sentence while we are at it.  Someone
  previously fixed same style run-on a few lines later, but this
  case was apparently overlooked.}

  [413:24] "the name of a local entity and" ->
  "a local identifier in the scoping unit;"

  [413:26-27] "the name of a local entity" ->
  "a local identifier in the scoping unit"

  [413:28] "Entities that are local (16.2) to" ->
  "Local identifiers of"

  {We have a separate and suitable definition of "local variable",
  so use it to simplify this edit; only variables can be initialized
  in DATA statements.}

  [413:29,30] "local entity" -> "local variable" (twice)


Edits elsewhere

  [17:5] "is a local entity of" -> "has a local identifier in"

  [257:35] "entity" -> "identifier"

  [428:3-5]. Change to

    <<automatic data object>> (5.1) : A data object that is not a
    dummy argument, but is declared in a subprogram to have a length
    type parameter or array bound that is specified by an expression
    that is not an initialization expression.

  [432:20] "entity" -> "identifier" (twice)

  [433:38] "local entity" -> "local identifier"

  [433:38] "An entity identified by a" -> "A"


--------------080609030508000007000801--

