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,772ae8afc5db35f2 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Can't export object of private type Date: 1999/03/01 Message-ID: #1/1 X-Deja-AN: 450047992 References: <7b3f6v$lc1$1@nnrp1.dejanews.com> <7b5u87$s88$1@nnrp1.dejanews.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1999-03-01T00:00:00+00:00 List-Id: robert_dewar@my-dejanews.com writes: > The advantage of private parts is of course the nice > compartmentalization. Indeed we have on the drawing boards > for GNAT a feature to have the private parts in separate > files which will be very handy for target specialization > and indeed for general abstraction. This would help in a situation I just encountered. I'm interfacing to a hardware device, so I've written a thin Ada binding package to the device driver. I'd like to make that thin binding private, so normal users can't use it. But I'd also like to use it in the private part of the public, thick binding: package SBS_Device is pragma Pure; -- just a root package end SBS_Device; private package SBS_Device.Thin is type Low_Level_Device_Type is record ... end record; end SBS_Device.Thin; with SBS_Device.Thin; -- illegal! package SBS_Device.Thick is type Device_Type is private; ... private type Device_Type is record Low_Level : SBS_Device.Thin.Low_Level_Device_Type; ... end record; end SBS_Device.Thick; "with SBS_Device.Thin" is illegal, because it's a private package. If the private part of SBS_Device.Thick were in a separate file, I could put the with clause there, and everybody would be happy. In my code, I made Low_Level a pointer, and deferred the full type to the body, where I can with SBS_Device.Thin. Perhaps an alternate solution would be to allow the keyword "private" in context clauses: with private SBS_Device.Thin; package SBS_Device.Thick is ... The semantics being that the private package is only allowed to be referenced in the private part. -- Stephe