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.105.69 with SMTP id e66mr14751663pgc.44.1480452702861; Tue, 29 Nov 2016 12:51:42 -0800 (PST) X-Received: by 10.157.20.197 with SMTP id r5mr1371915otr.9.1480452702797; Tue, 29 Nov 2016 12:51:42 -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!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!p16no3104016qta.1!news-out.google.com!m27ni4811qtf.1!nntp.google.com!n6no3105253qtd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Nov 2016 12:51:42 -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 20:51:42 +0000 Content-Type: text/plain; charset=UTF-8 X-Received-Bytes: 2689 X-Received-Body-CRC: 4013663922 Xref: news.eternal-september.org comp.lang.ada:32518 Date: 2016-11-29T12:51:42-08:00 List-Id: 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, I'm talking about how to map underlying ideas uniformly -- IOW, this topic is *NOT* about "how do I do _X_ in Ada?" but rather "How is Ada doing X best [uniformly] represented?". > 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_.