From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,57228cde5a9481bb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-18 10:50:47 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!noc.near.net!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: Change to obscure visibility rule in 9x Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: Date: Tue, 18 Oct 1994 17:38:30 GMT Date: 1994-10-18T17:38:30+00:00 List-Id: In article , Paul Graham 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.)