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!news.eternal-september.org!feeder.eternal-september.org!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Static_Predicate on array-types. Date: Fri, 18 Jul 2014 18:05:27 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1405721099 13251 192.74.137.71 (18 Jul 2014 22:04:59 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 18 Jul 2014 22:04:59 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:IjhQ+Lb7qZAZKQKBLLMOteFhzZs= Xref: news.eternal-september.org comp.lang.ada:21051 Date: 2014-07-18T18:05:27-04:00 List-Id: Shark8 writes: > Is there any particular reason why we cannot put static-predicates on an > array-type, such as (e.g.) to ensure that some condition always holds? > > Example, we want an unbounded array, but to ensure the first index is > always 1: > Type One_Based_Vector is Array(Positive Range <>) of Integer > with Static_Predicate => One_Based_Vector'First = 1; What advantage would that have over using Dynamic_Predicate (or in GNAT, Predicate)? If you want to know the rationale for the predicate rules, take a look at the AI that introduced them: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai05s/ai05-0153-3.txt which I wrote. You might be able to guess from the discussion that I disagreed with the decision to have two aspects Static_Predicate and Dynamic_Predicate. I preferred to have a single aspect Predicate, which is either static or dynamic depending on what the expression is. Just like for "X: constant T := expression;", X is a static constant if the expression is static. There's a GNAT-specific aspect Predicate, which is equivalent to Static_Predicate if that would be legal, and Dynamic_Predicate otherwise. - Bob