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,7d3cb5920e882220 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Contracted exceptions for Ada Date: Sun, 09 Dec 2007 17:09:53 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <7m9wkymyi5h7.1235e72is9mp9.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1197238194 13971 192.74.137.71 (9 Dec 2007 22:09:54 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 9 Dec 2007 22:09:54 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:zz4BOc6WYU/nVL9DAvw6kcncCk8= Xref: g2news1.google.com comp.lang.ada:18833 Date: 2007-12-09T17:09:53-05:00 List-Id: "Dmitry A. Kazakov" writes: > No problem. Exception contracts should be inheritable. File open would say > "I raise this and that and also anything disk driver does." (I remember > Robert Duff proposed that once.) I think what I proposed was more like what you say below: >> what about >> call-back routines (think Process in the Containers library); and so on. > > Conditional contracts: container's Forall is exception E free if Process > is. Right -- an iterator needs to be able to say "I can raise anything raised by the loop-body procedure that is passed in to me." That's one thing missing from Java, which makes exception contracts more painful than they need to be. Passing a procedure to an iterator causes the compiler to lose useful information. I think preconditions could help a lot in this general area -- instead of saying "I might raise Divide_By_Zero" on the divide procedure, one can specify exactly what circumstances cause that exception -- Divide_By_Zero will be raised if and only if you try to divide by zero. Then if at the call site, you divide by X, and X is Positive, there's no need for a handler. Unfortunately, there's no Non_Zero subtype. - Bob