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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61e9062c1f23b9d5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: contracted exceptions Date: Thu, 07 Jun 2007 16:04:20 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> <19fxsxv1god43$.1pqq8vgfu2itn$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1181246660 14482 192.74.137.71 (7 Jun 2007 20:04:20 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 7 Jun 2007 20:04:20 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:YV4Gv0USyOshDcwmXTJJJ2ab5v4= Xref: g2news1.google.com comp.lang.ada:16093 Date: 2007-06-07T16:04:20-04:00 List-Id: Ray Blaak writes: > "Dmitry A. Kazakov" writes: >> I would like to see contracted exceptions... > > The Java experience shows that compiler checked exception > specifications don't work. I don't quite agree. I'd say the Java experience shows that the exact rules of Java don't work very well. But that does not imply that the whole idea can't work well. I think Java is on the right track here, and with a few tweaks to the rules would work quite well. One example of a "tweak": if (in Ada) you have: procedure Iterate (..., Action: not null access procedure (...)); you want some way to say "Iterate can raise anything that Action can raise". The actual parameter passed to Action, I mean. Also, Java has a way to suppress the rules when appropriate, by making the exception "unchecked". But this method is not flexible enough, plus they chose the wrong answer for some of the predefined exceptions. > A typical naive programmer, forced by the compiler to handle an exception, Well, the compiler isn't doing the forcing, the programmer who defined the exception is. And you're not forced to handle it; you also have the choice of declaring it to be propagated. > overwhelmingly seems to do: [...lots of reasonable complaints about Java snipped] > If one observes what actually is needed for exception processing it tends to > be: > > a) abort control flow - the current op cannot proceed. > b) report the error to the user in a central way (in a popup, via a log, > whatever), and either exit or wait for the next new input/action. True of some programs. But many embedded systems have no use for popping up or logging. - Bob