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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.223.198 with SMTP id v66mr30338454yhp.21.1417009008612; Wed, 26 Nov 2014 05:36:48 -0800 (PST) X-Received: by 10.140.102.239 with SMTP id w102mr434qge.28.1417009008590; Wed, 26 Nov 2014 05:36:48 -0800 (PST) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!s7no2000192qap.1!news-out.google.com!m4ni578qag.1!nntp.google.com!s7no2000188qap.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 26 Nov 2014 05:36:48 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.197.113.215; posting-account=Ies7ywoAAACcdHZMiIRy0M84lcJvfxwg NNTP-Posting-Host: 24.197.113.215 References: <969708583438656051.436159nonlegitur-futureapps.invalid@reader80.eternal-september.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <36d3098c-c4e8-468d-aa40-852ffb535311@googlegroups.com> Subject: Re: How to get nice with GNAT? From: brbarkstrom@gmail.com Injection-Date: Wed, 26 Nov 2014 13:36:48 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:191046 Date: 2014-11-26T05:36:48-08:00 List-Id: On Wednesday, November 26, 2014 8:06:28 AM UTC-5, Dmitry A. Kazakov wrote: > On Wed, 26 Nov 2014 12:55:39 +0100, Georg Bauhaus wrote: > > > On 26.11.14 08:35, Simon Wright wrote: > >> Not an argument that applies to point-defence missile systems! > > > > That's good to know. I take it to mean that exceptions will less > > frequently have this tendency to backfire, an effect that checking > > return values in C can so easily produce: > > > > extern int foo(...); > > > > > > if (foo(...) < 0) { > > /* do something assuming that negative return values > > are error codes. */ > > > > > > And forgot overflow + wrap around. Ouch! > > > > This is another argument against > > > > when others => > > > > in Ada programs, too, unless there is a very good reason to include > > a catch-all. > > If exceptions were under a contract, the list of possible exceptions to > catch would be definite and quite small in most cases. So, actually, we > could disallow "when others" for all subprograms having an exception > contract and calling only such subprograms (statically). > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de The idea of creating an "exception contract" sounds useful. In a bit more formal setting, the list of specific exceptions might become part of a design audit procedure. It would show what kinds of exceptional conditions the designers and and coders had considered. when others => should probably be treated as a bad design unless the handler re-raises the exception before finishing. Bruce B. coders