comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Spark_IO: improving with postconditions?
Date: Wed, 26 Aug 2009 01:57:05 -0700 (PDT)
Date: 2009-08-26T01:57:05-07:00	[thread overview]
Message-ID: <a6cc46c0-eab3-4a77-b3dd-ee870d85c936@18g2000yqa.googlegroups.com> (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



             reply	other threads:[~2009-08-26  8:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-26  8:57 Maciej Sobczak [this message]
2009-08-26  9:23 ` Spark_IO: improving with postconditions? Georg Bauhaus
2009-08-26 14:47   ` xavier grave
2009-08-26 15:47     ` Georg Bauhaus
replies disabled

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