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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Ada 2012 Constraints (WRT an Ada IR) Date: Wed, 14 Dec 2016 12:04:46 +0100 Organization: A noiseless patient Spider Message-ID: References: <999c67b0-4478-4d2b-8108-32ac48fe6316@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 14 Dec 2016 11:03:23 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d7777aaea4e05f5460ede15b9236d665"; logging-data="11657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GsG59SNaBkYJB8bwFDG1ldGszpm/JVQo=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Cancel-Lock: sha1:IX64s0W9LjoMcQnohT56duvpvd4= Xref: news.eternal-september.org comp.lang.ada:32810 Date: 2016-12-14T12:04:46+01:00 List-Id: On 14/12/2016 09:42, Dmitry A. Kazakov wrote: > > The precondition here is *not* (Y in Positive), it is (Y in Integer). It is legal to call X on any Integer. Checking Y>=0 is semantically a part of the X's body, even if the compiler could inline this part at the caller's side or optimize it or the rest of the body away. And this is where Design by Contract, by intent, would differ from current choice of Ada's defensive style: The programmer is NOT allowed to just call an operation when there is a Pre aspect that says: Don't! So, by intent, if you declare procedure X (Y : Positive) with Pre => Y > 0; then a client programmer is required, by contract, to not call X with a non-positive Integer. If he or she does, then the programmer is violating the contract, and held responsible for any damage caused by the body of X. This is what contract based programming is all about.