comp.lang.ada
 help / color / mirror / Atom feed
* Declaration of function in precondition
@ 2014-04-24 10:12 Simon Wright
  2014-04-24 15:22 ` Adam Beneschan
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Wright @ 2014-04-24 10:12 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-25  1:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 10:12 Declaration of function in precondition Simon Wright
2014-04-24 15:22 ` Adam Beneschan
2014-04-25  1:45   ` Randy Brukardt

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