comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Declaration of function in precondition
Date: Thu, 24 Apr 2014 11:12:55 +0100
Date: 2014-04-24T11:12:55+01:00	[thread overview]
Message-ID: <lyzjjbt4rc.fsf@pushface.org> (raw)

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?

[1] http://stackoverflow.com/questions/23203022/ada-aspects-which-are-private-to-a-package

             reply	other threads:[~2014-04-24 10:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 10:12 Simon Wright [this message]
2014-04-24 15:22 ` Declaration of function in precondition Adam Beneschan
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