From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jarthur!petunia!news From: nwebre@polyslo.CalPoly.EDU (Neil Webre) Newsgroups: comp.lang.ada Subject: Re: Pre-condition vs Post-condition Message-ID: <27e4ff9d.346c@petunia.CalPoly.EDU> Date: 18 Mar 91 17:57:49 GMT Reply-To: nwebre@polyslo.CalPoly.EDU (Neil Webre) Organization: Cal Poly State Univ,CSC Dept,San Luis Obispo,CA 93407 List-Id: 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.