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 autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bellcore!uunet!igor!rutabaga!jls From: jls@rutabaga.Rational.COM (Jim Showalter) Newsgroups: comp.lang.ada Subject: Re: Pre-condition vs. Post-condition Keywords: pre-condition, post-condition, exception Message-ID: Date: 21 Mar 91 03:06:39 GMT References: <2865@sparko.gwu.edu> <97779@tut.cis.ohio-state.edu> <311@nic.cerf.net> <2938@cod.NOSC.MIL> Sender: news@Rational.COM List-Id: >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. Exactly. Some are better handled by status parameters, or status fields in abstract data types, or whatever. > 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. Exactly. Although I do think there are heuristics, such as the infrequency criterion. For example, I have no problem with blowing up on underflow instead of pre-checking it. But I wouldn't use an exception to implement a cyclic type, since the whole point of a cyclic type is that it will be cycled through, so using the exception on 'succ is poor form. In short, I use exceptions whenever their being raised would signal to someone in a debugger that something undesirable has occurred. Underflowing a stack is undesirable. Cycling a type is normal, so trapping that in a debugger would confuse the hell out of the maintenance programmer (it brings in the oxymoronic notion of a "normal exception"!). -- ***** DISCLAIMER: The opinions expressed herein are my own. Duh. Like you'd ever be able to find a company (or, for that matter, very many people) with opinions like mine. -- "When I want your opinion, I'll read it in your entrails."