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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.70.66 with SMTP id k2mr5386530igu.7.1398352975740; Thu, 24 Apr 2014 08:22:55 -0700 (PDT) X-Received: by 10.182.33.4 with SMTP id n4mr28554obi.9.1398352975536; Thu, 24 Apr 2014 08:22:55 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!c1no3095665igq.0!news-out.google.com!gi6ni629igc.0!nntp.google.com!l13no10426290iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 24 Apr 2014 08:22:55 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5a38852c-512e-43c4-9c02-cdcf105f0397@googlegroups.com> Subject: Re: Declaration of function in precondition From: Adam Beneschan Injection-Date: Thu, 24 Apr 2014 15:22:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.dca.giganews.com comp.lang.ada:186070 Date: 2014-04-24T08:22:55-07:00 List-Id: 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