comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: on OO differnces between Ada95 and C++
Date: 1996/02/22
Date: 1996-02-22T00:00:00+00:00	[thread overview]
Message-ID: <4ghupa$10f5@watnews1.watson.ibm.com> (raw)
In-Reply-To: 4gg6da$8jk@wdl1.wdl.loral.com

In article <4gg6da$8jk@wdl1.wdl.loral.com>, mab@dst17.wdl.loral.com
(Mark A Biggar) writes: 

|> Given the above example, is the following code legal, I have been unable to
|> determine if it is from the RM95: 
|>
|> with Parent.Child;
|> package My_Package is
|>
|>   A: Parent.Child.Auxiliary_Type;  -- or must I say A: Parent.Auxiliary_Type
|>
|> end My_Package;

No, it is illegal.  The effect of the with clause is as if you were
compiling My_Package in the following context: 

   package Parent is
      ...
      type Auxiliary_Type is ...;
      ...
      package Child is
         ...
      end Child;
   end Parent;

   package My_Package is
      ...
   end My_Package;

so you must say Parent.Auxiliary_Type.

|> If the above is illegal then it presents a problem if I have a library
|> level renaming of Parent.Child, like so: 
|>
|> package My_Child renames Parent.Child;
|>
|> with My_Child;
|> package Foo is
|>
|>   A: My_Child.Auxiliary_Type; -- LEGAL?
|>
|> end Foo;

Not legal, and there is no way to name Auxiliary_Type inside Foo, because
Parent is not visible there.  (AARM 10.1.2(9.b))  If you want to name an
entity exported by Parent (and not reexported), the name Parent must
appear in the with clause (possibly as a prefix).  This makes you write a
slightly longer with clause, but it is a very helpful property for
program readers trying to determine the origin of an entity named in Foo.

|> If this type of naming is legal then there is a simple emulation of
|> Norman's multi-part package proposal using child packages and a library
|> level rename.

It's not, but in any event my proposal allows a public part of a package
to refer to entities declared in an earlier private part of the package,
while still allowing the public part to be mentioned anywhere in a with
clause.  You can't do that with public and private children, because of
restrictions on where you can name private children in a with clause.

--
Norman H. Cohen    ncohen@watson.ibm.com




  reply	other threads:[~1996-02-22  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-20  0:00 on OO differnces between Ada95 and C++ Nasser Abbasi
1996-02-20  0:00 ` Robert I. Eachus
1996-02-20  0:00 ` Jerome Desquilbet
1996-02-21  0:00   ` Robert Dewar
1996-02-22  0:00     ` Jerome Desquilbet
1996-02-24  0:00       ` Robert Dewar
1996-02-22  0:00   ` Pete Becker
1996-02-23  0:00     ` Jerome Desquilbet
1996-02-26  0:00     ` Darren C Davenport
1996-02-26  0:00       ` Pete Becker
1996-02-27  0:00         ` Nigel Perry
1996-02-20  0:00 ` Norman H. Cohen
1996-02-21  0:00   ` Mark A Biggar
1996-02-22  0:00     ` Norman H. Cohen [this message]
1996-02-27  0:00   ` Adam Morris
1996-02-21  0:00 ` Darren C Davenport
1996-02-21  0:00 ` Jon S Anthony
1996-02-21  0:00 ` John English
1996-02-22  0:00   ` Nasser Abbasi
1996-02-26  0:00     ` John English
1996-02-27  0:00       ` Dale Stanbrough
1996-02-22  0:00   ` Gene Ouye
1996-02-26  0:00     ` John English
  -- strict thread matches above, loose matches on Subject: below --
1996-02-21  0:00 Christian Jaensch, FRG
1996-02-26  0:00 Simon Johnston
replies disabled

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