From: Jeffrey Carter <spam@spam.com>
Subject: Re: semi-visibility
Date: Fri, 13 Jun 2003 01:37:21 GMT
Date: 2003-06-13T01:37:21+00:00 [thread overview]
Message-ID: <3EE92ACC.8010302@spam.com> (raw)
In-Reply-To: YR8Ga.121540$d51.192359@sccrnsc01
tmoran@acm.org wrote:
> I want to do the following, but it's illegal. What's a good way to
> accomplish the purpose, preferably without increasing the depth of
> the package heirarchy, or enlarging package A.
>
> private package A.B is
> type Visible_To_Relatives is ...
> end A.B;
>
> with A.B;
> package A.C is
> type T is private;
> procedure P(x : in T);
> private
> type T is record
> v : A.B.Visible_To_Relatives;
> end record;
> end A.C;
One solution is to wait for Ada 0X. It has a way to to do this; IIRC,
it's "with private".
If you need it sooner, one solution is
private
type T_Implementation;
type T is access [all] T_Implementation;
end A.C;
This gets you into possible problems with initialization and
finalization that you might be able to alleviate by using Ada.Finalization.
A simpler solution is to make A.B non-private and attempt to enforce a
rule that it only be referenced in the private parts and bodies of
children of A.
--
Jeff Carter
"C's solution to this [variable-sized arrays] has real problems,
and people who are complaining about safety definitely have a point."
Dennis Ritchie
next prev parent reply other threads:[~2003-06-13 1:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-13 0:25 semi-visibility tmoran
2003-06-13 1:37 ` Jeffrey Carter [this message]
2003-06-13 23:08 ` semi-visibility Randy Brukardt
2003-06-13 3:40 ` semi-visibility Steve
2003-06-13 4:11 ` semi-visibility tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox