comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Silly and stupid post-condition or not ?
Date: Thu, 2 Feb 2012 21:13:04 -0600
Date: 2012-02-02T21:13:04-06:00	[thread overview]
Message-ID: <jgfjc4$u4b$1@munin.nbi.dk> (raw)
In-Reply-To: 82k445fu9n.fsf@stephe-leake.org

"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:82k445fu9n.fsf@stephe-leake.org...
...
> I agree with Dmitry; post conditions should be _complete_. If the Ada
> post condition language is not strong enough to be complete, don't use
> it; use natural language comments.

That's a pretty silly position, it essentially says that everything that 
makes Ada great is not worthwhile because it only can detect a portion of 
the problems. If you really believe this, you might as well be programming 
in a dynamically typed language, because then there is essentially no 
benefit to what Ada provides.

For instance, if you have an object

           Dart_Score : Natural range 1 .. 60; -- Holds the score for a 
single dart.

The range 1 .. 60 is not a complete specification of the possible scores. 
(For instance, 58 is not a possible score, but it is allowed by the range.) 
But even so, this specification still catches a lot of errors. Your comment 
above denies this and says that it is better to just have the comment rather 
than the range (because it is not "complete" in some sense).

[Aside: Ada 2012 has a way to make this complete, but of course there are 
many other things that are too hard to describe.]

My philosophy is that it is always preferable to at least be able to tell 
the compiler what you (the programmer) knows about a program entity. That 
allows the compiler and other tools to make checks (both compile-time and 
run-time) about that information -- and my years of experience shows me that 
those checks catch a lot of bugs (but by no means all). Moreover, as tools 
and compilers get better, they get able to do more with the information they 
are given, so you want to give them as much information as you can now --  
it's a lot harder to retrofit that information in after the fact.

So I want to describe as much as I can in terms of contracts (preconditions, 
postconditions, predicates, constraints, exclusions, and invariants for Ada 
2012, hopefully exception and data contracts in the future), but not to the 
extent of necessarily requiring completeness. At some point it just gets too 
hard.

I've always hated the emphasis on completeness of these things, because it 
is *exactly* the wrong approach to getting something in wide-spread use 
(even in the Ada community). Something like SPARC, that requires an 
all-or-nothing approach, very often ends up with nothing.

OTOH, an approach that just applies the easiest contracts first sets up a 
positive feedback loop for newcomers to Ada. They'll add a few range 
constraints and discover that those have detected some bugs early (possibly 
even at compile time). Which encourages them to add more contracts, which 
discovers more bugs early, and so on. That's how *I* learned the real 
benefits of Ada years ago - and I find it hard to believe that I'm unusual.

I think that things like SPARC can actually be harmful, as they focus 
attention on the wrong things. There is a lot that can be proved about 
dynamic constructs in Ada (far more than in other most languages), and it is 
unfortunate that instead of taking advantage of this (and making widely 
usable results), most of effort has been on proving the Fortran 66 subset of 
Ada. (I do see signs that this is changing, finally, but I think a lot of 
the work should have been done years ago.)

                                                    Randy.





  parent reply	other threads:[~2012-02-03  3:13 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 23:11 Silly and stupid post‑condition or not ? Yannick Duchêne (Hibou57)
2012-01-31  6:47 ` J-P. Rosen
2012-01-31 18:48   ` Jeffrey Carter
2012-01-31 22:02     ` Yannick Duchêne (Hibou57)
2012-01-31  8:54 ` Dmitry A. Kazakov
2012-01-31  9:35   ` Georg Bauhaus
2012-01-31 10:22     ` Dmitry A. Kazakov
2012-01-31 12:33       ` Georg Bauhaus
2012-01-31 13:52         ` Dmitry A. Kazakov
2012-01-31 15:34           ` Georg Bauhaus
2012-01-31 16:24             ` Dmitry A. Kazakov
2012-01-31 19:44               ` Georg Bauhaus
2012-02-01  8:41                 ` Dmitry A. Kazakov
2012-02-01 10:37                   ` stefan-lucks
2012-02-01 10:51                     ` Yannick Duchêne (Hibou57)
2012-02-01 13:49                     ` Yannick Duchêne (Hibou57)
2012-02-01 13:49                     ` Dmitry A. Kazakov
2012-02-01 16:37                       ` stefan-lucks
2012-02-02  1:50                         ` Silly and stupid post�?'condition " Randy Brukardt
2012-02-02  1:56                           ` Silly and stupid postâ?'condition or not ? Yannick Duchêne (Hibou57)
2012-02-03  2:45                             ` Silly and stupid post�?'condition or not ? Randy Brukardt
2012-02-02  8:25                         ` Silly and stupid post‑condition " Dmitry A. Kazakov
2012-02-02  9:01                           ` stefan-lucks
2012-02-02  9:18                           ` stefan-lucks
2012-02-02 10:04                             ` Dmitry A. Kazakov
2012-01-31 22:08         ` Yannick Duchêne (Hibou57)
2012-01-31 17:28 ` Dmitry A. Kazakov
2012-01-31 22:12   ` Yannick Duchêne (Hibou57)
2012-02-01  8:49     ` Dmitry A. Kazakov
2012-02-01  8:36 ` Stephen Leake
2012-02-01 16:30   ` Silly and stupid post-condition " Adam Beneschan
2012-02-02  9:40     ` Stephen Leake
2012-02-02 13:20       ` Georg Bauhaus
2012-02-02 13:35         ` Yannick Duchêne (Hibou57)
2012-02-03  3:13       ` Randy Brukardt [this message]
2012-02-03  3:33         ` Yannick Duchêne (Hibou57)
2012-02-03  8:12         ` Simon Wright
2012-02-07  2:29           ` BrianG
2012-02-07 10:43             ` Simon Wright
2012-02-08  2:25               ` BrianG
2012-02-07 21:15             ` Robert A Duff
2012-02-03  9:11         ` Dmitry A. Kazakov
2012-02-04  3:27           ` Randy Brukardt
2012-02-04 10:15             ` Dmitry A. Kazakov
2012-02-03 12:25         ` Phil Thornley
2012-02-04  9:30         ` Phil Thornley
2012-02-04 12:02         ` Phil Thornley
2012-02-05  6:18           ` Randy Brukardt
2012-02-05 10:23             ` Phil Thornley
2012-02-05 10:55               ` Yannick Duchêne (Hibou57)
2012-02-05 15:03               ` Robert A Duff
2012-02-05 18:04                 ` Phil Thornley
2012-02-05 21:27                   ` Robert A Duff
2012-02-05 23:09                     ` Phil Thornley
2012-02-07  2:05               ` Randy Brukardt
2012-02-07  9:38                 ` Dmitry A. Kazakov
2012-02-05 11:31             ` Yannick Duchêne (Hibou57)
2012-02-05 14:50             ` Robert A Duff
2012-02-07  2:11               ` Randy Brukardt
2012-02-07  2:34             ` BrianG
2012-02-07  4:38               ` Yannick Duchêne (Hibou57)
2012-02-09  3:10               ` Randy Brukardt
2012-02-04 23:07         ` Stephen Leake
2012-02-05  2:49           ` Yannick Duchêne (Hibou57)
2012-02-05  6:29           ` Randy Brukardt
2012-02-05 11:40             ` Yannick Duchêne (Hibou57)
2012-02-07  1:36               ` Randy Brukardt
2012-02-05 15:16             ` Robert A Duff
2012-02-06  4:56               ` Yannick Duchêne (Hibou57)
2012-02-06 14:39                 ` Robert A Duff
2012-02-06 16:12                   ` Yannick Duchêne (Hibou57)
2012-02-07  1:46               ` Randy Brukardt
2012-02-07 17:24                 ` Robert A Duff
2012-02-03  6:26       ` J-P. Rosen
2012-02-03  9:12         ` Dmitry A. Kazakov
2012-02-03  9:48           ` Yannick Duchêne (Hibou57)
2012-02-03 11:09             ` Dmitry A. Kazakov
2012-02-03 11:40               ` Yannick Duchêne (Hibou57)
2012-02-03 13:18                 ` Dmitry A. Kazakov
2012-02-03 14:14                   ` Yannick Duchêne (Hibou57)
2012-02-03 14:45                     ` Dmitry A. Kazakov
2012-02-04  3:16           ` Randy Brukardt
2012-02-04  6:27             ` Yannick Duchêne (Hibou57)
2012-02-04 10:47             ` Dmitry A. Kazakov
replies disabled

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