comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff Creem" <jeff@thecreems.com>
Subject: Re: Ada 0y wish list: "with private"
Date: Mon, 12 Feb 2001 19:13:54 -0500
Date: 2001-02-12T19:13:54-05:00	[thread overview]
Message-ID: <t8guui7s5ff6ef@corp.supernews.com> (raw)
In-Reply-To: 968p1e$8m7$1@s1.read.news.oleane.net


I am not entirely wild about this. It seems like a great way to break the
private abstraction and shoot
yourself. If C needs to need to know that much about B then it should be a
child of B.

Sure having something like this lets you be a little sloppier about the
interfaces you provide to users of
your package but without more of an example my gut tells me that you are
missing the reason things are
put in the private section.

"Thierry Lelegard" <thierry.lelegard@canal-plus.fr> wrote in message
news:968p1e$8m7$1@s1.read.news.oleane.net...
> Recently, several wishlist items for Ada 0y were posted in c.l.a.
> Like many old Ada users, I have a couple of them. I would like to
> propose one for discussion: a "with private" extension.
>
> The idea is to specify in a context clause of a unit spec that an
> external unit can be used only in the private part.
>
> Example:
>
> with A;
> with private B;
> package C is
>    X : A.TA;
> private
>    Y : B.TB; -- legal only in private part
> end C;
>
> There are two advantages:
>
> 1) Readability. The user of package C is only interested in the public
>    interface of C. Reading "with private B", the user knows that he may
>    safely ignore what the strange unit B is all about.
>
> 2) Use of private packages in private parts. Example:
>
> package Lib is ...
>
> private package Lib.Internals is ....
>
> with private Lib.Internals;
> package Lib.Public is
>     ....
> private
>     type TP is new Lib.Internals.TI ...
> end Lib.Public;
>
> The second point is, of course, more important than the first one. Some
> of my recent code could have been much simpler with such a possibility.
> In Ada 95, a private package cannot be referenced at all in the spec
> of a public package, even in the private part, since the context clause
> "with Lib.Internals" is simply refused.
>
> Two points:
> - The "with private" syntax is, of course, only a suggestion.
> - Maybe there is some implementation flaw that I missed.
>
> Any ideas or objections?
> -Thierry
>
____________________________________________________________________________
>
> Thierry Lelegard, "The Jazzing Troll", Email:
thierry.lelegard@canal-plus.fr
> CANAL+ Technologies, 34 place Raoul Dautry, 75516 Paris Cedex 15, France
> Tel: +33 1 71 71 54 30   Fax: +33 1 71 71 52 08   Mobile: +33 6 03 00 65
75
>
____________________________________________________________________________
>
>





  parent reply	other threads:[~2001-02-13  0:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-12 13:41 Ada 0y wish list: "with private" Thierry Lelegard
2001-02-13  0:10 ` Keith Thompson
2001-02-13  0:13 ` Jeff Creem [this message]
2001-02-13  6:37   ` Dale Stanbrough
2001-02-13 12:01     ` Jeff Creem
2001-02-13  8:48 ` Dr Adrian Wrigley
2001-02-13  8:56 ` Michel Gauthier
2001-02-13 16:31 ` Ehud Lamm
  -- strict thread matches above, loose matches on Subject: below --
2001-02-15  1:04 Beard, Frank
2001-02-15  4:18 ` Jeffrey Carter
2001-02-15  4:53 Christoph Grein
2001-02-15 19:16 Beard, Frank
replies disabled

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