comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Quantified expressions: no support for restriction predicates
Date: Fri, 27 Apr 2012 18:43:51 -0500
Date: 2012-04-27T18:43:51-05:00	[thread overview]
Message-ID: <jnfavs$frf$1@munin.nbi.dk> (raw)
In-Reply-To: 22242340.4097.1335486547825.JavaMail.geo-discussion-forums@vbki8

<phil.clayton@lineone.net> wrote in message 
news:22242340.4097.1335486547825.JavaMail.geo-discussion-forums@vbki8...
...
>I can see the lack of restriction predicates being a potential 'gotcha' 
>when writing/transforming
> pre/postconditions, e.g. incorrectly converting
>
>  not (for all X in T => if Odd(X) then P(X))
>
>into
>
>  (for some X in T => if Odd(X) then not P(X))

This is not a problem, since both of these are illegal. :-) Conditional 
expressions always have to be directly enclosed in parens, and that isn't 
done here. (There are special cases to allow the omission of those parens 
when they are already *directly* there, but in only those cases, like P(if 
Odd(X) then not P(X)); but not P(Param => if Odd(X) then not P(X));.)

Has nothing to do with your point, though.

...
>I haven't followed all the developments in the areas of predicates. 
>Perhaps there are good reasons
> not to have such restriction predicates.  Anyway, just thought I would 
> raise the idea as they seem useful.

We decided to leave all of the contract expressions as code easily 
understandable by any novice Ada programmer (or middle-aged Ada programmer 
who has forgotten most of the advanced mathematics he once knew - like, say, 
me :-).

Conditional expressions and quantified expressions themselves were both a 
bit controversial for this reason. We added conditional expressions mainly 
so that implications and the like could be specified without having to write 
a separate function (which of course would defy compile-time analysis as the 
body wouldn't be present). We rejected the idea of an "implies" operator 
because a lot of people are confused by what it means -- the equivalent 
conditional expression is much clearer, especially at 2 am!

Quantified expressions are hard enough to understand as it is. I don't think 
complicating them further would be helpful, especially for the programmer 
that only saw them rarely (which is likely to be most Ada programmers).

                                         Randy. 





  reply	other threads:[~2012-04-27 23:44 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 [this message]
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
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