comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: LLQ: Scope and child package names
Date: 2000/08/11
Date: 2000-08-11T00:00:00+00:00	[thread overview]
Message-ID: <wccbsz0dodt.fsf@world.std.com> (raw)
In-Reply-To: 8mv91i$bfr$1@nnrp1.deja.com

Ted Dennison <dennison@telepath.com> writes:

> My compiler's giving me some suprising (to my small mind) results in
> this area, so I'd like to find out what the actual rules are in this
> area.
> 
> Say I have two child packages, one of which "with"s the other. Let's
> further stipulate that the name of the with-ee's parent happens to be
> the same as the name of the with-or. For example:
> 
> package Foo.Utility is
>    type Instance is...
> ...
> end Foo.Utility;
> 
> with Foo.Utility;
> 
> package Facility.Foo is
> ...
>    type Instance is new Foo.Utility.Instance;
> end Facility.Foo;
> 
> My compiler gacks at this, saying Utility is not found in Foo. I'm
> guessing the problem is that "Foo" inside of Facility.Foo is a shorthand
> for Facility.Foo, hiding any "Foo" package hierarchy I may have with'ed.
> Is that right?

Yes.

Child packages behave (more or less) as if they were physically nested
in their parent.  Imagine that you had written these packages physically
nested, and then imagine which Foo hides which other Foo where.  Make
sense?

Eg:

procedure Main is
    package Foo is
        package Utility 
    ...etc

> Question 2:
> 
> It just so happened that I had a rename for the with-ee parent around.
> So I tried using that, expecting failure becuase I had no such rename
> for the child package. But to my suprise, it worked! Eg:
> 
> package Executive_Foo renames Foo;
> 
> with Executive_Foo.Utility;
> 
> package Facility.Foo is
> ...
>    type Instance is new Executive_Foo.Utility.Instance;
> end Facility.Foo;
> 
> This compiled happily. So a rename of a package effectively acts as a
> rename for all its children too?

There's nothing special about children when it comes to renaming.  If
you have a name for a package, you can refer to stuff in the package if
that stuff is visible, by saying Package_Name.Whatever.  It doesn't
matter whether Package_Name is a renaming or not.  And it doesn't matter
whether Whatever is a child package, or a nested package, or an integer
type nested in the package, or anything else.  The only thing special is
that children aren't visible unless with'ed.

- Bob




      reply	other threads:[~2000-08-11  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-10  0:00 LLQ: Scope and child package names Ted Dennison
2000-08-11  0:00 ` Robert A Duff [this message]
replies disabled

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