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: Robert Dewar Subject: Re: Exiting from a function or procedure Date: 2000/04/24 Message-ID: <8e059m$3u$1@nnrp1.deja.com>#1/1 X-Deja-AN: 614796746 References: <8duvlj$opk$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x43.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Apr 24 00:42:33 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-04-24T00:00:00+00:00 List-Id: In article , tmoran@bix.com wrote: > if not OK then > Log_And_Raise_Error; > end if; > return some_value; > end some_function; I find the above code a very poor choice, precisely because, as Tom notes, it will worry a maintenance programmer as to what is going on! Far better is if not OK then Log_And_Raise_Error; raise Program_Error; end if; or if you want to take the effort if not OK then Log_And_Raise_Error; raise Impossible_Exception_Cannot_Be_Raised; Still for those using GNAT, use the opportunity to learn about pragma No_Return, since it is a very clear way of documenting the special case of a procedure that never returns. By the way, I think it is a terrible design choice in Ada 95 that Raise_Exception can return to the caller. We end up special casing this in GNAT to avoid the warning in this case (raising Program_Error seems reasonable enough if Raise_Exception returns and the return path is unblocked. Sent via Deja.com http://www.deja.com/ Before you buy.