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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada 2012 Constraints (WRT an Ada IR) Date: Tue, 20 Dec 2016 12:00:53 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <1af458a8-cf5b-4dd7-824d-eed1ed5ffb21@googlegroups.com> NNTP-Posting-Host: s3c6wwRqkurrfTZpuYYZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Mozilla-News-Host: news://news.aioe.org Xref: news.eternal-september.org comp.lang.ada:32924 Date: 2016-12-20T12:00:53+01:00 List-Id: On 2016-12-19 23:33, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:o32vjg$1jv4$1@gioia.aioe.org... >> On 2016-12-16 20:51, Randy Brukardt wrote: > ... >>> The path was that set by Ada 83 with the idea of constraints. By your >>> model, >>> constraint checks belong to the implementation, and those have always >>> been >>> exposed in the specification. >> >> Not explicitly. It is like the implementation of "+" when an integer type >> declared. The implementation is assumed but not specified. > > Explicitly, by the semantic model I quoted earlier. > >>> Later versions of Ada have just built on this >>> already existing (and very successful) idea, extending it to further >>> cases. >> >> I meant explicit code snippets in declarations, which includes "is null", >> checks, etc. >> >> It is very different from having type operations producing new [sub]types >> like >> >> subtype Y is X range 1..100; >> >> or >> >> type T is array (I) of E; >> >> They declare and implement operations implicitly. > > Only in your world-view, Sure. > not the official Ada semantics, for a subtype. Which must be fixed. > Operations are only declared for a type, not a subtype (and the location of > declaration matters). > > And I'm not sure why > subtype Y is X range 1 .. 100; > is OK and > subtype Z is X with Static_Predicate => Z > 0; > is not. They both have explicit declarations of the subtype, and the > semantics is effectively the same. The former declares a continuous range from which the semantics of numeric operations and attributes can be deduced. For the later, nobody has any idea without looking at the expression = implementation. "Effectively same" is meaningless on its own. The generated object code is "effectively same" too. As I said, it is low-level and useless from SW design POV. You must be able to answer questions like if you used Z in an algorithm of X, would it work? If not, how, when, where etc. A range allows answering such questions, an arbitrary constraint does not. The only things deducible from an arbitrary constraint are assignment and equality comparison. Already enumeration types have more operations than these. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de