From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,68448d6fdcce63ae X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Protected Objects: Scoping problem. Date: 1998/06/17 Message-ID: #1/1 X-Deja-AN: 363588400 References: <6m3kj4$ev0@nntp02.primenet.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1998-06-17T00:00:00+00:00 List-Id: Robert Worne 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; -- Stephe