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 2002:ac8:2ff3:: with SMTP id m48mr7536897qta.127.1573228515513; Fri, 08 Nov 2019 07:55:15 -0800 (PST) X-Received: by 2002:aca:450:: with SMTP id 77mr10067843oie.113.1573228515278; Fri, 08 Nov 2019 07:55:15 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!j16no707336qtl.0!news-out.google.com!g53ni56qtg.0!nntp.google.com!j16no707332qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 8 Nov 2019 07:55:14 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=185.22.143.114; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 185.22.143.114 References: <21fa6db8-4b86-459f-bc5a-70993f92c28a@googlegroups.com> <27cb5366-4b3d-4f33-b8ec-2bc71c70780c@googlegroups.com> <530a0f85-158a-4c42-b826-04ae4bd46451@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How to best make a custom range? From: AdaMagica Injection-Date: Fri, 08 Nov 2019 15:55:15 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57524 Date: 2019-11-08T07:55:14-08:00 List-Id: Am Dienstag, 5. November 2019 16:10:46 UTC+1 schrieb Shark8: > TYPE Digits is range 0..9; > SUBTYPE Odds is Digits with Static_Predicate => Odds in 1|3|5|7|9; > what should Odds'Pred(1) be? 0? Constraint_Error? > what about Odds'Pos(1) should it be 0, the first item of the subtype? Or 1, the position in the parent-type? Attributes work on the base type, e.g. Natural'Pred (0) = -1 Constraints on the subtype are ignored, Digit'Pred and Odds'Pred are identical. Thus: Odds'Pred (8) = 7 -- 8-1 Odds'Pos (2) = 2 -- result is universal_integer Of course, this will raise an exception: X: Odds := Odds'Pred (7); -- 6 not in Odds Y: Odds := Odds'Pos (8); -- universal_integer 8 converted into Digits not in Odds