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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: How to get nice with GNAT? Date: Sun, 23 Nov 2014 10:02:25 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sun, 23 Nov 2014 17:02:13 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="6bb4f0a3c21c874c69dbcaa30e818f24"; logging-data="28044"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195KJnoOkCR3NqFIe00XmgLuqCidbEPjzw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: Cancel-Lock: sha1:509aiOK+SaGzZp2bb89TCKKyhss= Xref: number.nntp.giganews.com comp.lang.ada:190971 Date: 2014-11-23T10:02:25-07:00 List-Id: On 11/23/2014 09:13 AM, brbarkstrom@gmail.com wrote: > > That is not correct. I routinely set OK := False; at the beginning > of the procedure and only set it to True when the procedure has completed > correctly. The output from the procedure does provide the last value > of OK before the procedure raises the exception -- if the procedure doesn't > handle the exception. This is compiler-dependent behavior. Your code is not portable. > if (Bad_Condition = True) then if Bad_Condition then Comparing Boolean variables to Boolean literals usually indicates someone who doesn't understand Booleans. > The code that calls This_Procedure can choose how it wants to handle > the exception. For example, > > ... > This_Procedure(OK => OK, > Err_Msg => Err_Msg); > if not OK then > Put_Line(Vstring.To_String(Err_Msg)); > -- Take other exception handling steps > end if; If the call to This_Procedure raises an exception, execution will not get to the if statement. > ... > > will print out the error message. I'll grant the programmer may have > to handle complex chains of exception handling. However, it does work > and can provide the thread of exceptions for understanding what happened. > > Also, this is one strategy for dealing with exceptions in Web interfaces, > where it's important to avoid a fatal error that shuts down a working > program that's interacting with users. > > I use this approach routinely. It is a big help during debugging. If > the exception handling is left in, it can also catch problems when the > debugging has moved along and you've forgotten about it. That saves > time. > > Bruce B. > -- Jeff Carter "This school was here before you came, and it'll be here before you go." Horse Feathers 48