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.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!apple!agate!dog.ee.lbl.gov!nosc!cod!sampson From: sampson@cod.NOSC.MIL (Charles H. Sampson) Newsgroups: comp.lang.ada Subject: Re: Pre-condition vs. Post-condition Keywords: pre-condition, post-condition, exception Message-ID: <2938@cod.NOSC.MIL> Date: 19 Mar 91 20:38:57 GMT References: <2865@sparko.gwu.edu> <97779@tut.cis.ohio-state.edu> <311@nic.cerf.net> Organization: Computer Sciences Corporation List-Id: In article <311@nic.cerf.net> sss@nic.cerf.net (Marlene M. Eckert) writes: >How about exceptions should be raised only in _EXCEPTIONAL_ >situations? Reaching the end-of-file or trying to POP off an >empty stack are NOT exceptional conditions. O. K., but that just pushes the issue off to deciding what the word _exceptional_ means. The definition I prefer to use is: "An exceptional condition is one that occurs infrequently or unexpectedly." (Not original, but I forgot whom I stole it from. I think it was John Barnes.) When teaching Ada, immediately after giving that definition I point out to the students that it does not require all exceptional conditions to be handled by exceptions. What's happening here is that we're in an area where a lot of design decisions have to be made. I'm not sure that there is a rule that can be applied to all cases and I am sure that if there is one we haven't found it yet. Unlike Mike Feldman, I have no philosophical problem with using End_error to detect end-of-file or stack underflow to determine that the stack is now empty, both satisfying the _infrequent_ criterion. (I doubt that I would ever use the latter myself, but my reasons are more esthetic than anything else.) Before I would condemn these uses in any particular situation, I would want to hear the reasons for them. This has been an interesting thread to follow as we grapple with this problem. I particularly appreciate the fact that very few dogmatic positions have been put forward. Charlie