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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3467cec1612741de X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-20 14:10:32 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!titan03.ksc.nasa.gov!niven.ksc.nasa.gov!usenet From: "Samuel T. Harris" Newsgroups: comp.lang.ada Subject: Re: Tables vs functions (was Re: Anonymous array clarification.) Date: Mon, 20 Aug 2001 16:02:09 -0500 Organization: Raytheon Aerospace Engineering Services Message-ID: <3B817AD1.2DA2DF70@gsde.hou.us.ray.com> References: <3b80c13f$1@pull.gecm.com> <9lrhcn$9lc$1@nh.pace.co.uk> Reply-To: samuel_t_harris@raytheon.com NNTP-Posting-Host: sstf-fw.jsc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX64 6.2 IP19) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:12145 Date: 2001-08-20T16:02:09-05:00 List-Id: Marin David Condic wrote: > > Or as an alternative: > > > function Tomorrow(A_Day : in Day) return Day is > > begin > > return Day'Succ(A_Day); > exception > when Constraint_Error => > return Day'First ; > > end Tomorrow; > > There is, of course, going to be some debate about using exceptions for > conditions you expect to happen. However, I'd point out that the code is a > bit more brief and that in some implementations it might be (on the average) > faster - for whatever that's worth. Its just an alternate implementation > style. :-) > > Which would I personally use? I'd usually go with what you described. There > may be occasional uses of the Constraint_Error trap in things I write of > this nature - I'm partial to that technique when implementing saturated > arithmetic. Dunno if there is any consensus that it should be one way or > another in this case - but its a good one to put in a programming style > guideline. Like formatting rules, I'd go with whatever the style guide > recommends for a given project. Consider this ... I'm using my debugger to trap an unhandled constraint_error and I have to skip over this one several times before I can get to the real one. For this reason alone I prefer to do my own checking whenever possible. -- Samuel T. Harris, Senior Software Engineer II Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"