[comp.lang.ada] Use clauses in the visible parts of packages???

gyro@kestrel.edu (Scott Layson Burson) (03/28/91)

So here I am implementing an Ada front end (for an analysis system,
not a compiler) and I'm working on use clauses, and I seem to have
found a case which is not mentioned in the manual, nor can I find any
mention of it in the commentaries.  To wit: what happens if a use
clause appears among the basic declarative items in the visible part
of a package specification?  Do the identifiers made directly visible
by the use clause become part of the package's visible declarations?

Now, it seems to me that either:

 1) The use clause does augment the package's visible declarations,
    and this is not the slightest bit problematic -- the various
    existing rules cover the fine points of the situation perfectly
    well.  This seems unlikely, because it's the kind of thing the LRM
    would typically include a helpful note about.

 2) Despite the fact that the syntax allows use clauses in visible
    parts of packages, nobody but me has ever actually thought of
    putting one there.  This seems unlikely because of the amount of
    time people have spent poring over the specification and the
    number of extant implementations.

 3) The relevant rules are in the LRM or commentaries somewhere, but
    I haven't found them.  This seems unlikely because there aren't
    many places in the manual where I would expect to find such rules,
    and grepping through the commentaries turns up a short list of
    instances of "use clause", among which I have found no reference
    to this possibility.

Can anyone help me out?

-- Scott Burson
Gyro@Reasoning.COM

stluka@software.org (Fred Stluka) (03/29/91)

In article <1991Mar27.200047.21167@kestrel.edu> Gyro@Reasoning.COM writes:
> ... To wit: what happens if a use
> clause appears among the basic declarative items in the visible part
> of a package specification?  Do the identifiers made directly visible
> by the use clause become part of the package's visible declarations?

No.  The identifiers are only made visible to the "scope" of 
the use clause, which does not include other packages which 
"with" the package containing the use clause.

Section 8.4(4) says:

     In order to define which declarations are made directly visible 
     at a given place by use clauses, consider the set of packages
     named by all use clauses whose scopes enclose this place...
                                           ^^^^^^^

The "scope" of a use clause is defined in 8.4(3) as:

     For each use clause, there is a certain region of text called
     the "scope" of the use clause.  This region starts immediately
     after the use clause.  If the use clause is a declarative item 
     of some declarative region, the scope of the clause extends to
     the end of the declarative region. ...

--Fred

-- 

Fred Stluka                              Internet: stluka@software.org
Software Productivity Consortium         UUNET:    ...!uunet!software!stluka
2214 Rock Hill Rd, Herndon VA 22070 USA