comp.lang.ada
 help / color / mirror / Atom feed
From: nwebre@polyslo.CalPoly.EDU (Neil Webre)
Subject: Re: Pre-condition vs Post-condition
Date: 18 Mar 91 17:57:49 GMT	[thread overview]
Message-ID: <27e4ff9d.346c@petunia.CalPoly.EDU> (raw)



When the questions of exceptions and pre- and post-conditions came up,
I answered by mail to the poster. Since there have been some replies
via news, I am posting my reply which follows:

To: cml8@robin.cs.uofs.edu
Subject: Re: Pre-condition vs. Post-condition
Organization: Cal Poly State Univ,CSC Dept,San Luis Obispo,CA 93407

   If a pre-condition is not met, the result of execution is undefined
   (maybe unspecified is a better word). In the case of exceptions, if
   you write the fact that an exception will occur in certain cases,
   in your postcondition, then it seems to me that you have written
   a specification of results if the "error" condition happens. Therefore
   the error condition was not a precondition since your algorithm
   has a well defined and specified result for that case. 

   I am in the process of writing a textbook. What we have done is to
   write the specs of procedures and functions in the following form:

   procedure kaboom(...);
   -- precondition : ....
   -- postcondition : ....
   -- exceptions : ...

   Properly speaking, the exceptions clause is part of the postcondition.
   However, since exceptions are a standard way of handling "errors"
   in Ada, we broke them out into a separate clause.
   Preconditions are reserved to screen out conditions that truly have no
   defined results. It is the job of the client to assure that the
   precondition is met prior to execution of the procedure or function.

      

             reply	other threads:[~1991-03-18 17:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-03-18 17:57 Neil Webre [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-03-16 14:42 pre-condition vs post-condition Ed Knoll @(719)593-5182
replies disabled

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