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: border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: {Pre,Post}conditions and side effects Date: Tue, 12 May 2015 10:02:54 +0200 Organization: A noiseless patient Spider Message-ID: References: <2430252d-52a1-4609-acef-684864e6ca0c@googlegroups.com> <0a718b39-ebd3-4ab5-912e-f1229679dacc@googlegroups.com> <9ee5e186-5aaa-4d07-9490-0f9fdbb5ca18@googlegroups.com> <87tww5296f.fsf@adaheads.sparre-andersen.dk> <871tj9dp5b.fsf@theworld.com> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 12 May 2015 08:01:45 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b96887e80893c84a90c3007226ca0d1c"; logging-data="27001"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wP0INM7a75afmr4wjn6fHGcngo9ynInY=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: Cancel-Lock: sha1:2gH6GuTNkI92Ch2vHxSv4G9+QwM= Xref: number.nntp.giganews.com comp.lang.ada:193140 Date: 2015-05-12T10:02:54+02:00 List-Id: On 12.05.15 03:03, Randy Brukardt wrote: > No, I'd still argue your code is broken. If*you* know that some object is > always sorted, then*you* should tell the compiler that with an appropriate > predicate: > > subtype Sorted_Array is Some_Array > with Dynamic_Predicate => Is_Sorted (Sorted_Array); > > My_Array : Sorted_Array := ...; There is no formal specification of what Is_Sorted should be. But there should be one, somewhere (other than a comment), even when the formal specification involves quite a bit. How is a client of Sorted_Array to know what Is_Sorted should be? And if the contract has that information hidden in RM style commentary, how would the cost of keeping Some_Array sorted plus having it checked be so different from the supplier side cost of checking that assumption? This sounds like shifting responsibility for commercial reasons, again.