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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Ray Blaak Subject: Re: Exiting from a function or procedure Date: 2000/04/22 Message-ID: #1/1 X-Deja-AN: 614395869 Sender: blaak@ns55.infomatch.bc.ca References: <8ds3qe$q2d$1@nnrp1.deja.com> X-Trace: news.bc.tac.net 956431921 207.34.170.119 (Sat, 22 Apr 2000 12:32:01 PDT) NNTP-Posting-Date: Sat, 22 Apr 2000 12:32:01 PDT Newsgroups: comp.lang.ada X-Complaints-To: news@bctel.net Date: 2000-04-22T00:00:00+00:00 List-Id: 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, I also prefer a single return point, so I would have written: result := default_value; if OK then result := ok_value; else Log_And_Raise_Error; end if; return result; end some_function; -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, blaak@infomatch.com The Rhythm has my soul.