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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,75ce2ead897158b2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.106.161 with SMTP id gv1mr88437wib.4.1365187103647; Fri, 05 Apr 2013 11:38:23 -0700 (PDT) MIME-Version: 1.0 From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: My bug or else regarding Visibility Rules Date: Thu, 28 Mar 2013 17:03:13 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <0c77e832-e12b-446d-af24-78d77c358f1e@googlegroups.com> <25ee066d-3270-4efd-829f-ed40b04c0655@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1364508197 10049 69.95.181.76 (28 Mar 2013 22:03:17 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 28 Mar 2013 22:03:17 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Path: ex12ni25015wid.1!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.130.MISMATCH!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.stben.net!texta.sil.at!news.ecp.fr!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail Date: 2013-03-28T17:03:13-05:00 List-Id: "Adam Beneschan" wrote in message news:25ee066d-3270-4efd-829f-ed40b04c0655@googlegroups.com... > On Thursday, March 28, 2013 12:54:26 PM UTC-7, Anh Vo wrote: >> For the codes below GNAT complains that In_Index, Buffer, and Out_Index >> are undefined. > However, if I comment out private key word, GNAT is happy. Did I violate > Ada syntax rules? Thanks. > > 13.1.1(11): The usage names in an aspect_definition [ are not resolved at > the point of the >associated declaration, but rather] are resolved at the end of the >immediately enclosing declaration list. > > In your example, the "immediately enclosing declaration list" ends at the > keyword PRIVATE > when that keyword is present; but if you take it out, the declaration list > ends at "end Circular_Queue;". Which is the long way to say that the expression of a public aspect has to be made up only of public functions and objects. Otherwise, how would a caller be able to figure out the meaning of a precondition that they are required to meet? Clients can never be required to look in a private part. This, BTW, is one of the reasons we added expression functions to Ada 2012. For a lot of these cases, you might as well let the compiler know what the actual object is, because then it probably can generate better code and possibly remove part or all of some of these checks. Thus using a function completed with an expression function in the private part essentially lets the compiler "peek" into private part. (Peeking into bodies is much harder, especially as bodies can be changed without changing the specification.) Randy.