* semi-visibility
@ 2003-06-13 0:25 tmoran
2003-06-13 1:37 ` semi-visibility Jeffrey Carter
2003-06-13 3:40 ` semi-visibility Steve
0 siblings, 2 replies; 5+ messages in thread
From: tmoran @ 2003-06-13 0:25 UTC (permalink / raw)
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;
with A.B;
package A.D is ...
-- private part here similarly needs visibility of A.B
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: semi-visibility
2003-06-13 0:25 semi-visibility tmoran
@ 2003-06-13 1:37 ` Jeffrey Carter
2003-06-13 23:08 ` semi-visibility Randy Brukardt
2003-06-13 3:40 ` semi-visibility Steve
1 sibling, 1 reply; 5+ messages in thread
From: Jeffrey Carter @ 2003-06-13 1:37 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: semi-visibility
2003-06-13 0:25 semi-visibility tmoran
2003-06-13 1:37 ` semi-visibility Jeffrey Carter
@ 2003-06-13 3:40 ` Steve
2003-06-13 4:11 ` semi-visibility tmoran
1 sibling, 1 reply; 5+ messages in thread
From: Steve @ 2003-06-13 3:40 UTC (permalink / raw)
Is there some reason you don't want to put type Visible_To_Relatives in the
private part of A?
Steve
(The Duck)
<tmoran@acm.org> wrote in message news:YR8Ga.121540$d51.192359@sccrnsc01...
> 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;
>
> with A.B;
> package A.D is ...
> -- private part here similarly needs visibility of A.B
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: semi-visibility
2003-06-13 3:40 ` semi-visibility Steve
@ 2003-06-13 4:11 ` tmoran
0 siblings, 0 replies; 5+ messages in thread
From: tmoran @ 2003-06-13 4:11 UTC (permalink / raw)
>Is there some reason you don't want to put type Visible_To_Relatives in the
>private part of A?
Just that A is already bigger than I'd like.
But I've decided that once again, if Lady Ada slaps my wrist, she's right
and I didn't really want to do that anyway. In this case that means
creating package A.BCD and renaming to A.BCD.C and A.BCD.D, possibly followed
(for less verbosity) by "package A.C renames A.BCD.C;" etc.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: semi-visibility
2003-06-13 1:37 ` semi-visibility Jeffrey Carter
@ 2003-06-13 23:08 ` Randy Brukardt
0 siblings, 0 replies; 5+ messages in thread
From: Randy Brukardt @ 2003-06-13 23:08 UTC (permalink / raw)
Jeffrey Carter wrote in message <3EE92ACC.8010302@spam.com>...
>One solution is to wait for Ada 0X. It has a way to to do this; IIRC,
>it's "with private".
Actually, it's "private with" (see AI-262). And that's by far the best
solution, but it hasn't appeared in compilers yet.
Randy.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-06-13 23:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-13 0:25 semi-visibility tmoran
2003-06-13 1:37 ` semi-visibility Jeffrey Carter
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox