comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Static_Predicate on array-types.
Date: Fri, 18 Jul 2014 18:05:27 -0400
Date: 2014-07-18T18:05:27-04:00	[thread overview]
Message-ID: <wcc7g3a1fx4.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: qHVxv.59529$bf2.56097@fx24.iad

Shark8 <OneWingedShark@gmail.com> 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

  reply	other threads:[~2014-07-18 22:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17 19:43 Static_Predicate on array-types Shark8
2014-07-18 22:05 ` Robert A Duff [this message]
2014-07-21 22:35   ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox