comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: My bug or else regarding Visibility Rules
Date: Thu, 28 Mar 2013 17:03:13 -0500
Date: 2013-03-28T17:03:13-05:00	[thread overview]
Message-ID: <kj2en4$9q1$1@munin.nbi.dk> (raw)
In-Reply-To: 25ee066d-3270-4efd-829f-ed40b04c0655@googlegroups.com

"Adam Beneschan" <adam@irvine.com> 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.





  reply	other threads:[~2013-03-28 22:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 19:54 My bug or else regarding Visibility Rules Anh Vo
2013-03-28 20:58 ` Adam Beneschan
2013-03-28 22:03   ` Randy Brukardt [this message]
2013-03-30  6:05     ` Anh Vo
2013-04-02  0:56       ` Randy Brukardt
2013-04-02  1:52         ` Anh Vo
2013-04-02  8:26           ` Simon Wright
2013-04-02 18:17             ` Anh Vo
2013-04-02 20:16               ` Simon Wright
2013-04-03 23:21                 ` Anh Vo
2013-04-04  8:19                   ` Simon Wright
2013-04-04 19:21                     ` Anh Vo
2013-04-04 19:47                       ` Simon Wright
2013-04-02 22:04           ` Randy Brukardt
2013-03-28 22:06   ` Anh Vo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox