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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dabd2d2ffbcf1daa X-Google-Attributes: gid103376,public From: dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner) Subject: Re: Exiting from a function or procedure Date: 2000/04/22 Message-ID: <8dsu7h$8i41@news.cis.okstate.edu>#1/1 X-Deja-AN: 614409467 References: <8ds3qe$q2d$1@nnrp1.deja.com> Organization: Oklahoma State University User-Agent: slrn/0.9.6.2 (Linux) Reply-To: dstarner98@aasaa.ofe.org Newsgroups: comp.lang.ada Date: 2000-04-22T00:00:00+00:00 List-Id: On 22 Apr 2000 12:33:32 -0700, Ray Blaak wrote: >tmoran@bix.com writes: >> > So NEVER EVER ignore warnings, consider them as errors. In >> > fact you might want to use -gnatwe so the compiler will >> > treat them as errors enforcing this discipline. >> >> This is not always a good idea. For instance >> if OK then >> return some_value; >> else >> Log_And_Raise_Error; >> end if; >> end some_function; >> is a perfectly legitimate paradigm in Ada that would become >> illegal in Gnat with -gnatwe, since the compiler doesn't know >> that Log_And_Raise_Error will never return. > >I always put in a dummy return in these cases, just to avoid such warnings, and >for safety if the log routine ever *doesn't* raise an exception (e.g. maybe due >to some maintenance change in the future). Of course, that masks a bug. Log_And_Raise_Error is defined to raise an exception - if it doesn't then it's buggy. Either that, or the maintenance programmer should have fixed every use of Log_And_Raise_Error - and a dummy return is unlikely to be the correct fix. At least in developement, raising Program_Error is a good result. -- David Starner - dstarner98@aasaa.ofe.org Finger dvdeug@x8b4e53cd.dhcp.okstate.edu for more information. Only a nerd would worry about wrong parentheses with square brackets. But that's what mathematicians are. -- Dr. Burchard, math professor at OSU