comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: Declaration of function in precondition
Date: Thu, 24 Apr 2014 08:22:55 -0700 (PDT)
Date: 2014-04-24T08:22:55-07:00	[thread overview]
Message-ID: <5a38852c-512e-43c4-9c02-cdcf105f0397@googlegroups.com> (raw)
In-Reply-To: <lyzjjbt4rc.fsf@pushface.org>

On Thursday, April 24, 2014 3:12:55 AM UTC-7, Simon Wright wrote:
> I proposed this in answer to a question[1] on StackOverflow:
> 
> 
> 
>    package RingBuffer is
>       function Is_Full return Boolean;
>       procedure Push(value: T) with Pre => not Is_Full;
>       function Pop return T;
>    private
>       buffer: array(0..size) of T;
>       readptr: integer := 0;
>       writeptr: integer := 1;
>       function Is_Full return Boolean is (Readptr = Writeptr);
>    end RingBuffer;
> 
> and it turns out that GNAT (GPL 2013, 4.9-20140119) is happy if I put
> the spec of Is_Full after its use (but still in the visible part):
> 
>       procedure Push(value: T) with Pre => not Is_Full;
>       function Is_Full return Boolean;
> 
> I can't see where in the ARM this is legalised?

13.1.1(11), I think.  But I'm not sure.

"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."

                            -- Adam


  reply	other threads:[~2014-04-24 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 10:12 Declaration of function in precondition Simon Wright
2014-04-24 15:22 ` Adam Beneschan [this message]
2014-04-25  1:45   ` Randy Brukardt
replies disabled

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