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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,cb04cee6116c8ced,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!36g2000yqu.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.ada Subject: Package's private parts and protected types Date: Sun, 7 Feb 2010 20:30:30 -0800 (PST) Organization: http://groups.google.com Message-ID: <7ff3810f-3ee3-4f39-a54c-933ad7d0655c@36g2000yqu.googlegroups.com> NNTP-Posting-Host: 86.66.190.226 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1265603430 25928 127.0.0.1 (8 Feb 2010 04:30:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 8 Feb 2010 04:30:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 36g2000yqu.googlegroups.com; posting-host=86.66.190.226; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; fr),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8962 Date: 2010-02-07T20:30:30-08:00 List-Id: Hi all out there, Whenever a protected type is declared, all of its specification has to be defined at once and not private stuff can be delay (like "type ... is private" would allow). If this protected type is to hold something which is not to be public, the only way to do as far I'm able to do, is to wrap it in a private type as a record component. package P type A_Type is limited private; -- Must be limited, to be able to hold a limited component. function Value (A : A_Type) return Value_Type; -- Value_Type defined somewhere else. procedure Do_Something (A : in out A_Type); -- Potentially blocking. -- Obviously, there are comments to assert such things, -- but I would prefer it to be formally stated. private protected type B_Type is -- Cannot move it in the public part, due -- to a feature (Set_Value) which must not be public. function Value return Value_Type; -- Accessed via the corresponding method on A_Type. procedue Set_Value (New_Value : in Value_Type); -- The A_Type does not have such a corresponding -- method : we want it to remains private. procedure Do_Something; -- Accessed via the corresponding method on A_Type. -- B_Type being protected, this means this is -- a potentially blocking operation. end B_Type; type A_Type is limited record B : B_Type; end record; end P; Then, implementation of methods on A_Type will then simply pass control to the corresponding ones of its B component. All of this, just to hide something which is not to be part of the public specification. I don't like it, because it does not any more publicly shows that things relies on a protected object. Was this a desired consequence when this part of Ada was designed ? Do someone know a reason ? Is there something I'm doing here I should not do ?