From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Protected Objects: Scoping problem.
Date: 1998/06/17
Date: 1998-06-17T00:00:00+00:00 [thread overview]
Message-ID: <uemwnzzlr.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 6m3kj4$ev0@nntp02.primenet.com
Robert Worne <rworne@primenet.com> writes:
> I am having a problem with scoping on protected objects.
>
> I am working on a package that has a protected object that
> communicates to other packages via a "read". A "write" in that object
> should be visible only as an internal subprogram, and not visible to the
> outside world. A simplified version from the Ada documents on-line is:
>
> package Protected_Variable is
>
> type T is new integer;
>
> protected Variable is
> function Read return T;
> procedure Write(Value: T); -- I do NOT want this accessible to outside
> -- packages!
> private
> Data: T;
> end Variable;
> end Protected_Variable;
That's precisely what the private part of the protected type is for.
Just declare Write in the private part:
package Protected_Variable is
type T is new integer;
protected Variable is
function Read return T;
private
procedure Write(Value: T); -- NOT accessible to outside packages
Data: T;
end Variable;
end Protected_Variable;
<snip>
-- Stephe
next prev parent reply other threads:[~1998-06-17 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-15 0:00 Protected Objects: Scoping problem Robert Worne
1998-06-15 0:00 ` Matthew Heaney
1998-06-17 0:00 ` Stephen Leake [this message]
1998-06-17 0:00 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox