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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.99.111.133 with SMTP id k127mr15968123pgc.55.1480460381486; Tue, 29 Nov 2016 14:59:41 -0800 (PST) X-Received: by 10.157.11.248 with SMTP id 111mr1430653oth.4.1480460381417; Tue, 29 Nov 2016 14:59:41 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!n6no28150qtd.0!news-out.google.com!j8ni95qtc.0!nntp.google.com!p16no26985qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Nov 2016 14:59:41 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=174.28.218.229; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 174.28.218.229 References: <92ed75e9-baae-455c-9e34-53348dc6eaef@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada 2012 Constraints (WRT an Ada IR) From: Shark8 Injection-Date: Tue, 29 Nov 2016 22:59:41 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:32521 Date: 2016-11-29T14:59:41-08:00 List-Id: On Tuesday, November 29, 2016 at 2:06:21 PM UTC-7, Dmitry A. Kazakov wrote: > On 2016-11-29 21:51, Shark8 wrote: > > On Tuesday, November 29, 2016 at 1:44:43 PM UTC-7, Dmitry A. Kazakov wr= ote: > >> 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, >=20 > Yes you do, covariance vs. contravariance is semantics, not syntax. Maybe I'm misunderstanding. I simply don't see how covariance vs. contravariance is at all germane to r= epresenting the definition of a type. > >> 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 operati= on > >> in Ada, yet it is an operation. It must be covariant, i.e. returning t= he > >> new type rather than the old one for the case be satisfied with the ne= w > >> 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 so= me > >> predicate on the assignment operation (which Ada's predicates do). Tha= t > >> 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_. >=20 > What is abstracting making the type? Perhaps I should have used the word "defining" or "representing" instead of= "making". > In order to have a type you must=20 > define it =3D define the set of values, the set of operations, the=20 > semantics of the operations and provide an implementation of these=20 > (values representation, bodies of the operations) Agreed, but restating the motivation of the question isn't often helpful fo= r answering the question. -- Rather like if I were to wake at three in the = morning, ask myself "what should I do until sunrise?" and answer with "In a= few more hours, the sun will come up."... I mean, it's completely a true s= tatement... but useless for answering the question of what to do until then= .