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,start X-Google-Attributes: gid103376,public From: Robert Worne Subject: Protected Objects: Scoping problem. Date: 1998/06/15 Message-ID: <6m3kj4$ev0@nntp02.primenet.com>#1/1 X-Deja-AN: 362880437 Organization: Primenet (602)416-7000 X-Posted-By: rworne@206.165.6.209 (rworne) Newsgroups: comp.lang.ada Date: 1998-06-15T00:00:00+00:00 List-Id: 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; package body Protected_Variable is protected body Variable is function Read return T is begin return Data; end Read; procedure Write(Value: T) is begin Data := Value; end Write is separate; end Variable; end Protected_Variable; What I want is for the procedure "Write" to not be externally visible, as if it were commented out of the spec file. However, that makes it not visible to the package body (at least during elaboration). How can I accomplish this seemingly simple task? Am I going about it in a totally incorrect fashion? I need the mutual exclusion a protected object will provide, but in a read-only fashion to the outside. If anyone needs to know the compiler I'm using, it's ObjectAda. Although I tend to believe it's my problem and not the compiler's.