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, 29 Nov 2016 22:06:17 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <92ed75e9-baae-455c-9e34-53348dc6eaef@googlegroups.com> NNTP-Posting-Host: s3c6wwRqkurrfTZpuYYZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; 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.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:32519 Date: 2016-11-29T22:06:17+01:00 List-Id: On 2016-11-29 21:51, Shark8 wrote: > On Tuesday, November 29, 2016 at 1:44:43 PM UTC-7, Dmitry A. Kazakov wrote: >> On 2016-11-29 21:32, Shark8 wrote: >> >>> The above has a constraint -- that of only holding digits -- but >>> still is unconstrained. If we were doing a formal CS class we'd say something >>> like "The type Serial_Number contains all strings that have only the >>> decimal digits therein." >> >> You want convariance, that is a completely different beast. > > No, I really don't. > I'm not talking about Ada-syntax, Yes you do, covariance vs. contravariance is semantics, not syntax. >> It is a new >> type with some operations overridden, e.g. the operation that yields a >> value of a discrete type for case statement. It is an implicit operation >> in Ada, yet it is an operation. It must be covariant, i.e. returning the >> new type rather than the old one for the case be satisfied with the new >> set of values. Same with already mentioned 'First, 'Last, 'Range. Or, >> for that matter, 'Succ and 'Pred if the new type has a non-contiguous >> values set, e.g. Odd_Number. You cannot get there by merely putting some >> predicate on the assignment operation (which Ada's predicates do). That >> model is too weak to express such things. > > This is not about defining a type in Ada, it's about abstracting the > making of a type [in Ada] and how best to represent _that_. What is abstracting making the type? In order to have a type you must define it = define the set of values, the set of operations, the semantics of the operations and provide an implementation of these (values representation, bodies of the operations) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de