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, 21 Dec 2016 19:26:56 +0100 Organization: A noiseless patient Spider Message-ID: References: <1af458a8-cf5b-4dd7-824d-eed1ed5ffb21@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 21 Dec 2016 18:25:30 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c3a243ccd996b0e779e8c2533e7bdbcd"; logging-data="5875"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IWaspCM8r19V0L9xAmwpo4i0fbCS8FV8=" 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:6oXepntXzFJTapFFxJdzyHIakcE= Xref: news.eternal-september.org comp.lang.ada:32937 Date: 2016-12-21T19:26:56+01:00 List-Id: On 21/12/2016 16:56, Dmitry A. Kazakov wrote: > It is a continuous subset. This preserves a lot of properties like being a convex set a,b in S => (a+b)/2 in S etc. The subtype in question seems to be this: subtype Z_Too is X range X'Range -- 1 .. 100 with Static_Predicate => Z_Too > 0; I see no breaks there. But the subset of floors (of buildings) in the USA, arguably reflects normal expectations: subtype ZZ is X range X'Range with Static_Predicate => ZZ /= 13; V1 : constant ZZ := 13; -- compiler complains But! The Static_Predicate is *not* meant to be defining or implementing a type that excludes 13! Instead, it *should* be documenting a property of the ZZ objects that a correct algorithm is using. A useful curiosity for users of Float, maybe, type F is new Float with Static_Predicate => F /= 0.0; as in function A (...) return F; Then any checking before division, like in V := A (...); if V /= 0 then ... W / V ...; is truly useless. Will it be possible, in any normal project, to write a 0.0-excluding private type in Ada, say, thus making Static_Predicate strictly the equivalent of redundant, with all expectations on FPT still met? > That would produce non-sets. At compile time? Otherwise, how can a specification of membership by any Boolean function "produce" anything but that decision, if it does compute a result? Also, how can one predict, from a SW design POV or otherwise, that those "run-time sets" of subtypes do not reflect what the engineers had been carefully designing, and documenting that way?