From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ad4:4431:: with SMTP id e17mr2033698qvt.37.1616029445431; Wed, 17 Mar 2021 18:04:05 -0700 (PDT) X-Received: by 2002:a25:9303:: with SMTP id f3mr9012739ybo.165.1616029445226; Wed, 17 Mar 2021 18:04:05 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 17 Mar 2021 18:04:05 -0700 (PDT) In-Reply-To: <08b15573-0197-4b6e-9411-d0ca0f627f62n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=2601:193:4103:71a0:956a:5c4a:8722:ccd9; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 2601:193:4103:71a0:956a:5c4a:8722:ccd9 References: <89128f73-fcc5-4e57-8067-d09877ba0211n@googlegroups.com> <6ca041f3-2669-4497-9548-2f17666702a6n@googlegroups.com> <26c44e00-a899-455a-a929-1e23c7935fe3n@googlegroups.com> <9abb081d-a323-466d-9ae8-a2fc8fa24725n@googlegroups.com> <424f7220-abba-49df-8160-17851c336999n@googlegroups.com> <08b15573-0197-4b6e-9411-d0ca0f627f62n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7e1f3203-0fe9-428e-a8ac-411f432dca49n@googlegroups.com> Subject: Re: array from static predicate on enumerated type From: Matt Borchers Injection-Date: Thu, 18 Mar 2021 01:04:05 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61602 List-Id: On Wednesday, March 17, 2021 at 4:41:17 PM UTC-4, Shark8 wrote: > Because it's undefined, and the operations prohibited.=20 > You're jumping from "Let's have a continuous function" to "we can define = division by zero as something useful."=20 > And you can... but not automatically, and when someone brings up the func= tion F(x) =3D 1/x and says "well, we have to resolve this issue, as the lim= it to zero comes from negative it becomes -Infinity, but from positive it b= ecomes positive Infinity."=20 This sounds like a strawman argument. You're saying it can't work because = it doesn't work. I have a valid 1 to 1 mapping of values and that is the p= urest definition of a function. It is up to the programmer to define what = the mapping is. Static_Predicate is only defining the list of valid inputs= (and the order) to whatever I choose my mapping implementation to be. A p= rogrammatic function does not need to be continuous and nor can it be when = it is defined on an enumerated type. The parent enumeration has an order s= pecified in the program text and the sub-type also has an order. > The same thing is happening here: you're saying that 'pos, 'succ, etc cou= ld be defined -- and that's true -- but you're ignoring the underlying prob= lems.=20 > Having something like "P : Constant Array (Primes) of Natural;" could ind= eed be useful, but what would P(12) be? If Primes'Succ(11) =3D 13, then wha= t is Primes'Pred(2)? [This latter is a good example because in String manip= ulation, the 0 value is used for indicating things like "not-found", and we= absolutely can say SUBTYPE INDEXER IS VALUE'First..INDEX(VALUE, "NOEXIST")= ; and have it be sensible when INDEXER is the null-range.] Assuming, subtype Primes is Natural with Static_Predicate Primes in 2|3|5|7|9|11|13..= .; P : Constant Array (Primes) of Natural; What I would expect is that P(12) would be an illegal access because 12 is = not a valid value of Primes thus cannot be an index and a constraint error = or out-of-range error would be thrown. Wouldn't this just involve the comp= iler to insert "if x not in primes then raise..." if constraint checking is= enabled? Otherwise you have an erroneous program. Similarly, Primes'Succ= (12) is also illegal. Primes'Pred(2) also illegal because there is no prim= e before 2 so presumably you have defined your Static_Predicate to enumerat= e the primes with 2 listed first. A similar illegal invocation would be a = function F defined with an argument for Primes, like "function F( p : Prime= s ) return Natural is" and you called F(12). Regards, Matt