From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Visibility issue Date: Fri, 11 Sep 2020 23:05:45 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:60115 List-Id: On 11/09/2020 12:37, Daniel wrote: > I want to use a tagged type as a link to communicate users of a library, in the way to make one part visible to them and also to hide some content that is only needed for the implementing of the library. > > Lets say i have the "Library" packages to expose things to users, and Implementing_Library packages to deal with the implementation: > > package Library.Users is > type User_type is tagged with private; > procedure foo_public (S: User_Type); > private > type User_Type is tagged with record > hide_content_to_user : Natural; > end record; > function Access_to_hide_content return User_type; Why is this a primitive operation? I would consider rather function Access_to_hide_content return User_type'Class; In presence of potential overriding things like these are usually class-wide. > So, are there more ways to see the hided content of this tagged type without extending the type itself in a child package? I needed to see this content outside of Library package. You can also use aggregation: type User_type is tagged with private; private type User_type is tagged with record Implementation : Private_Stuff; end record; Private_Stuff may have its own hierarchy. This pattern works well with limited types. You want the interface being non-limited, but the implementation of limited in order to control/prevent excessive copying and support in-place updates. So you make the interface a holder or a smart pointer to the reference-counted implementation. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de