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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada 2012 Constraints (WRT an Ada IR) Date: Wed, 7 Dec 2016 16:37:30 -0600 Organization: JSA Research & Innovation Message-ID: References: <92ed75e9-baae-455c-9e34-53348dc6eaef@googlegroups.com> <03847fd7-5699-48de-bb3c-ef5512398f26@googlegroups.com> <3ef819e8-55f7-4ef7-9f37-77e6abc33f98@googlegroups.com> <47366b42-c0a3-41bf-a44a-5241c109d60f@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1481150246 32737 24.196.82.226 (7 Dec 2016 22:37:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 7 Dec 2016 22:37:26 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:32665 Date: 2016-12-07T16:37:30-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:o28mpn$1doo$1@gioia.aioe.org... > On 07/12/2016 00:09, Randy Brukardt wrote: ... > 2. This is a mixture of two independent things: > > 2.a an exception contract. Delete can raise Constraint_Error Which is being made explicit. > 2.b implementation. Delete must raise Constraint_Error at least when > Has_Element (Position) is false and in who knows which other cases and it > may raise Constraint_Error but not required to in some other undefined > cases... This happens because Ada doesn't (yet) have exception contracts (which apply to the body, not the precondition). If it did, it wouldn't include Constraint_Error (there being no other correct reason for raising Constraint_Error from delete). I want Ada to have exception contracts, precisely for reusable code like the containers. But there is a lot of opposition, mainly because experience with them in other languages (notably Java) isn't good. I believe that is because exception contracts mainly help code that is used by many projects (and thus the contract cannot change in any way without notice), and not so much within a single project (when changing details of contracts might be more work than benefit). In any case, Ada exception contracts would have to be optional, and the usage problems seem to happen when they are manditory. .. > Precondition would be a contract that does all potential callers, not a > very good thing to do, really. Of course it is a good thing to do, the alternative is to let callers call with anything they like (within the type system), which is obvious nonsense. Not everything can be described as a type (object state, for instance). Randy.