comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@dsd.camb.inmet.com (Bob Duff)
Subject: Re: Change to obscure visibility rule in 9x
Date: Tue, 18 Oct 1994 17:38:30 GMT
Date: 1994-10-18T17:38:30+00:00	[thread overview]
Message-ID: <CxvqC7.7Jv@inmet.camb.inmet.com> (raw)
In-Reply-To: GRAHAM.94Oct18094458@clsi.clsi.com

In article <GRAHAM.94Oct18094458@clsi.clsi.com>,
Paul Graham <graham@clsi.COM> wrote:
>
>Why did Ada 83 have this rule, and why did 9x eliminate it?
>
>    8.3(16) Within the specification of a subprogram, every declaration
>    with the same designator as the subprogram is hidden ... where
>    hidden in this manner, a declaration is visible neither by selection
>    nor directly.

The reason for the Ada 83 rule was to simplify compilers.  In Ada 9X,
the same effect is achieved by 8.2(2);5.0, which is, we believe, simpler
still.  This is explained in AARM-8.2(2.a):

 2   {immediate scope (of a declaration)} The immediate scope of a declaration
 is a portion of the declarative region immediately enclosing the declaration.
 The immediate scope starts at the beginning of the declaration, except in the
 case of an overloadable declaration, in which case the immediate scope starts
 just after the place where the profile of the callable entity is determined
 (which is at the end of the _specification for the callable entity, or at the
 end of the generic_instantiation if an instance).

	 2.a   Reason:  The reason for making overloadable declarations with
	 profiles special is to simplify compilation:  until the compiler has
	 determined the profile, it doesn't know which other declarations are
	 homographs of this one, so it doesn't know which ones this one should
	 hide.  Without this rule, two passes over the _specification or
	 generic_instantiation would be required to resolve names that denote
	 things with the same name as this one.

The Ada 83 rule had the same effect, but required a special case in the
compiler -- the compiler must have a flag indicating that it's in the
process of analyzing a subprogram_spec, and must remember the name of
the subprogram.  In Ada 9X, this special case is eliminated.

An example is given in AARM-8.3(29.j):

    29.j   The scope of a subprogram does not start until after its profile.
	 Thus, the following is legal:

 29.k        X : constant Integer := 17;
	     procedure X(Y : in Integer := X);

    29.l   The body of the subprogram will probably be illegal, however, since
	 the constant X will be hidden by then.

    29.m   The rule is different for generic subprograms, since they are not
	 overloadable; the following is illegal:

 29.n        X : constant Integer := 17;
	     generic
	       Z : Integer := X; -- Illegal!
	     procedure X(Y : in Integer := X); -- Illegal!

    29.o   The constant X is hidden from direct visibility by the generic
	 declaration.

None of this makes much difference to anybody except a language lawyer.

- Bob
-- 
Bob Duff                                bobduff@inmet.com
Oak Tree Software, Inc.
Ada 9X Mapping/Revision Team (Intermetrics, Inc.)



       reply	other threads:[~1994-10-18 17:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <GRAHAM.94Oct18094458@clsi.clsi.com>
1994-10-18 17:38 ` Bob Duff [this message]
1994-10-20  4:01   ` Change to obscure visibility rule in 9x Paul Graham
     [not found]   ` <GRAHAM.94Oct20000151@canopus.clsi.com>
1994-10-20 14:46     ` Bob Duff
     [not found] <INFO-ADA%94101904360935@vm1.nodak.edu>
1994-10-19 12:33 ` Bob Duff
1994-10-19  9:39 Simtel20 Transfer
  -- strict thread matches above, loose matches on Subject: below --
1994-10-18 13:44 Paul Graham
1994-10-18 15:23 ` Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox