comp.lang.ada
 help / color / mirror / Atom feed
From: phil.clayton@lineone.net
Subject: Re: Quantified expressions: no support for restriction predicates
Date: Tue, 1 May 2012 04:35:23 -0700 (PDT)
Date: 2012-05-01T04:35:23-07:00	[thread overview]
Message-ID: <11223559.107.1335872123955.JavaMail.geo-discussion-forums@vbxz8> (raw)
In-Reply-To: <wcc7gwywcuh.fsf@shell01.TheWorld.com>

On Sunday, April 29, 2012 8:35:18 PM UTC+1, Robert A Duff wrote:
> phil.c...@lineone.net writes:
> 
> > Is that actually possible for a Dynamic_Predicate?  Section 3.2.4 Subtype Predicates, para 27/3 says:
> >
> >   The discrete_subtype_definition of a loop_parameter_specification
> >   shall not denote ... or any subtype to which Dynamic_Predicate
> >   specifications apply.
> 
> Yeah, I think you're right.  The idea is that we didn't want hidden
> inefficiencies.
> 
>     type T is new Integer with
>         Dynamic_Predicate => T mod 10_000 = 0;
>     for X in T loop -- Illegal!
> 
> If that were legal, it would probably be grossly inefficient.

Right, this is the key point.  Writing pre- and postconditions where many elements are quantified over but immediately ignored due to a 'restriction predicate' is not good style, given these conditions are to be evaluated.  It would be preferable to quantify over just the elements that satisfy the restriction predicate in the first place.

For a subtype with a static predicate, presumably there is no efficiency issue because the restrictions placed on a static predicate enable the compiler to generate code that skips the elements not satisfying the predicate.

For static analysis, one would not worry about efficiency of evaluation and restriction predicates are common-place.  

Phil



  parent reply	other threads:[~2012-05-01 13:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  0:29 Quantified expressions: no support for restriction predicates phil.clayton
2012-04-27 23:43 ` Randy Brukardt
2012-04-28 11:30   ` phil.clayton
2012-04-29 14:03     ` Robert A Duff
2012-04-29 18:37       ` phil.clayton
2012-04-29 19:35         ` Robert A Duff
2012-05-01  2:48           ` Randy Brukardt
2012-05-01 11:35           ` phil.clayton [this message]
2012-04-30 15:57     ` Adam Beneschan
2012-05-01 11:14       ` phil.clayton
replies disabled

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