comp.lang.ada
 help / color / mirror / Atom feed
* Spark_IO: improving with postconditions?
@ 2009-08-26  8:57 Maciej Sobczak
  2009-08-26  9:23 ` Georg Bauhaus
  0 siblings, 1 reply; 4+ messages in thread
From: Maciej Sobczak @ 2009-08-26  8:57 UTC (permalink / raw)


The Spark_IO package defines several procedures that "return" string
values by filling the given String object and the end-of-sequence
index value. This end-of-sequence parameter is consistently defined
as:

Stop : out Natural

One example of such a function is:

   procedure Get_Line (File     : in     File_Type;
                       Item     :    out String;
                       Stop     :    out Natural);
   --# global in out Inputs;
   --# derives Inputs,
   --#         Item,
   --#         Stop     from Inputs, File;
   --# declare delay;

Wouldn't it be good to enhance this specification with additional:

   --# post Stop <= Item'Last;

It would save the caller from one redundant check if the Stop value is
ever used again as index into the returned string value.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



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

end of thread, other threads:[~2009-08-26 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-26  8:57 Spark_IO: improving with postconditions? Maciej Sobczak
2009-08-26  9:23 ` Georg Bauhaus
2009-08-26 14:47   ` xavier grave
2009-08-26 15:47     ` Georg Bauhaus

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