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!news4.google.com!out03b.usenetserver.com!news.usenetserver.com!in01.usenetserver.com!news.usenetserver.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Sat, 08 Dec 2007 13:01:13 -0500 From: "Peter C. Chapin" User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Exceptions References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475a8d6d$0$30677$4d3efbfe@news.sover.net> <145gsya555jlt$.8mvve9nqja9n$.dlg@40tude.net> In-Reply-To: <145gsya555jlt$.8mvve9nqja9n$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <475adbe8$0$30689$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: bbb83cc9.news.sover.net X-Trace: DXC=P@HVJOCE3?@`i3kGa5K\l=L?;Vke>Hf;9AMH1Se;J X-Complaints-To: abuse@sover.net Xref: g2news1.google.com comp.lang.ada:18789 Date: 2007-12-08T13:01:13-05:00 List-Id: Dmitry A. Kazakov wrote: > The problem here is not exception contracts but firstly lack of subtypes in > C++. Ada has subtypes, so the code above could be rewritten [properly]: > > if X in Safe_For_P1 then > declare > Checked_X : Safe_For_P1 renames X; > begin > P1 (Checked_X); -- This does not raise exception Here is my example again: if Has_Acceptable_Value(X) then P1(X); end if; What if Has_Acceptable_Value(X) returns true if X is prime... or a positive power of two? I don't believe you can use Ada subtypes to express conditions like that---or indeed many other possibilities. However, since primes (or positive powers of two, etc) aren't negative, my earlier point is still valid. The above code won't raise the exception in P1 (assume P1 only raises for negative arguments) so handling it or claiming to propagate it is a waste of resources and misleading. Peter