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!news3.google.com!out04b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!in03.usenetserver.com!news.usenetserver.com!pc02.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail 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> <475adbe8$0$30689$4d3efbfe@news.sover.net> From: Stephen Leake Date: Sun, 09 Dec 2007 05:24:51 -0500 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/22.1 (windows-nt) Cancel-Lock: sha1:iBu3KJQzoDJ0y58Es4xaf70IbR8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: d9f0f475bc26ce05e48ed01759 Xref: g2news1.google.com comp.lang.ada:18800 Date: 2007-12-09T05:24:51-05:00 List-Id: "Peter C. Chapin" writes: > 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. Right. You have to use SPARK Ada. -- -- Stephe