comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNAT packages in Linux distributions
Date: Thu, 13 May 2010 11:09:41 +0200
Date: 2010-05-13T11:09:37+02:00	[thread overview]
Message-ID: <zieelve702mf$.3aeqg197zg03.dlg@40tude.net> (raw)
In-Reply-To: Pine.LNX.4.64.1005130120450.26871@medsec1.medien.uni-weimar.de

On Thu, 13 May 2010 02:37:37 +0200, stefan-lucks@see-the.signature wrote:

> On Wed, 12 May 2010, Dmitry A. Kazakov wrote:
> 
>> On Wed, 12 May 2010 20:10:26 +0200, stefan-lucks@see-the.signature wrote:
>> 
>>> In Eiffel, I'll either get an answer, or the program will tell that at 
>>> some point of time when computing, say, the factorial of 100, a certain 
>>> exception has been raised. (I didn't try out Eiffel, but that is what I 
>>> would expect.) But if I get an answer, I can be sure it is the right one. 
>>> That is partial correctness. 
>> 
>> 1. Wrong answer is no more/less incorrect as an exception. 
> 
> We clearly disagree on this point. 
> 
> Consider being new in a town, and asking how to go from, say, the railway 
> station to the market place. If we ask a guy who appears to be a local 
> person in our eyes, but is actually as foreing as we are, most people 
> would prefer an exception "sorry, I don't know the way" over the answer of 
> being directed into the wrong direction. If you think, the "sorry" is as 
> bad as the wrong direction, that is your problem, which I am not 
> interested in discussing any further. 

Consider another example. Let you have a word processor, which also
calculates frequencies of some words. After typing dozen pages of the
document, you remove a word (the last instance, occasionally), and the
processor crashes on zero divide trying to calculate its new frequency. I
bet you would prefer a rubbish frequency displayed.

The bottom line, the effect of an error is undefined. You cannot define any
reasonable action upon, UNLESS further information were available. Which is
equivalent to *specification* of a behavior. Once the behavior is defined,
it is no more an error, e.g. the frequency of an unused word is displayed
as an empty string. It is a mere requirement. If you don't know the answer,
say "I don't know", do not shoot.

>> 2. It is unrelated to error checks. The programmer did not use any. That
>> Eiffel possibly checks for integer overflow and C does not is irrelevant to
>> the issue.
> 
> The exception may just as well be raised when checking the postcondition. 

or from an if-statement placed by the programmer.

>>    {Any Precondition}
>>     raise Program_Error; 
>>    {Postcondition}
> 
> Yes, that program is partially correct. 

I wouldn't consider it as such.

> Well, Hoare did originally not bother with exceptions,

BTW Hoare, wasn't it actually Edsger Dijkstra?

>> The problem is that Program_Error does not satisfy postcondition.
> 
>> His approach, which I greatly appreciate, is perfectly compatible with
>> exceptions. Exception propagation is a part of the program behavior to be
>> checked as anything else. E.g.
>> 
>>    pre : x = 1
>>    if x = 1 then
>>       raise Foo;
>>    end if;
>>    post : Foo propagating
>> 
>> This program were be incorrect if it would not raise Foo.
> 
> Now I see what you mean. You are asking for contracts which include 
> exception propagation. Yes, that would be nice to have. 

How could it be otherwise?

> Then you should like Eiffel, because this is what Eiffel actually does. In 
> Eiffel, the formal postcondition
> 
>   require P;
> 
> is a shortcut notation for the logical
>   
>   Postcondition: P or else (Postcondition_Violation propagating);
> 
> (whatever the name of the exception is), which is the real postcondition 
> of an Eiffel program. If Eiffel checks P at the end of the program, and 
> raises that exception when the check fails, then 
> 
>   Eiffel-programs are always correct!

Yes. Therefore a lazy programmer could write

   raise Postcondition_Violation;

and claim his salary.

> You don't even need to perform any static analysis to ensure their 
> correctness. (But you must not turn of the checks!)

Nice language, the program semantics depends on the compiler options. (We
have this in some places in Ada too, unfortunately)

> Of course the catch is that you would rather want to specify 
> postconditions which exclude exception propagation.

Yep.

>   -> Eiffel is a very expressive programming language, 
>      while SPARK is less expressive. 
> 
>   -> The language for contracts in SPARK is more expressive
>      than the language for contracts in Eiffel.

OK
 
> That doesn't mean that the contracts you can express in Eiffel are 
> invalid, however.

With the addition you made they are not. Once you remove
Postcondition_Violation (which can be done by a compiler switch), they
become invalid.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2010-05-13  9:09 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-09 17:40 GNAT packages in Linux distributions Dmitry A. Kazakov
2010-05-09 18:16 ` Ludovic Brenta
2010-05-09 19:36   ` Dmitry A. Kazakov
2010-05-09 21:26     ` Ludovic Brenta
2010-05-09 21:34       ` Yannick Duchêne (Hibou57)
2010-05-10  1:20         ` Ludovic Brenta
2010-05-10  1:26           ` Ludovic Brenta
2010-05-25 20:40             ` Yannick Duchêne (Hibou57)
2010-05-10  9:41         ` Stephen Leake
2010-05-10  9:46           ` Ludovic Brenta
2010-05-10 14:29             ` sjw
2010-05-11  7:51               ` Ludovic Brenta
2010-05-11  9:33                 ` sjw
2010-05-10 18:47           ` Yannick Duchêne (Hibou57)
2010-05-09 21:28     ` Yannick Duchêne (Hibou57)
2010-05-09 21:30       ` Yannick Duchêne (Hibou57)
2010-05-09 22:44       ` Simon Wright
2010-05-10  7:54         ` Dmitry A. Kazakov
2010-05-10  8:02       ` Dmitry A. Kazakov
2010-05-10 18:45         ` Yannick Duchêne (Hibou57)
2010-05-10 21:00           ` Ludovic Brenta
2010-05-10 22:17             ` Yannick Duchêne (Hibou57)
2010-05-11  6:56               ` Ludovic Brenta
2010-05-11  7:39           ` Dmitry A. Kazakov
2010-05-11  8:06             ` Yannick Duchêne (Hibou57)
2010-05-11 15:46             ` Pascal Obry
2010-05-11 16:05               ` Yannick Duchêne (Hibou57)
2010-05-11 16:09                 ` Pascal Obry
2010-05-11 16:09                   ` Pascal Obry
2010-05-11 17:08                     ` stefan-lucks
2010-05-11 16:39                       ` Yannick Duchêne (Hibou57)
2010-05-11 19:45                         ` Yannick Duchêne (Hibou57)
2010-05-11 23:44                           ` Yannick Duchêne (Hibou57)
2010-05-12 12:12                             ` Mark Lorenzen
2010-05-12 14:55                               ` Yannick Duchêne (Hibou57)
2010-05-11 17:35                       ` Pascal Obry
2010-05-11 18:06                         ` Yannick Duchêne (Hibou57)
2010-05-11 16:23                   ` Yannick Duchêne (Hibou57)
2010-05-11 16:41                     ` J-P. Rosen
2010-05-11 16:45                 ` Dmitry A. Kazakov
2010-05-11 19:21                   ` Yannick Duchêne (Hibou57)
2010-05-12  8:41                   ` stefan-lucks
2010-05-12 14:52                     ` Yannick Duchêne (Hibou57)
2010-05-12 15:59                       ` Phil Thornley
2010-05-12 16:49                         ` Yannick Duchêne (Hibou57)
2010-05-13  8:05                           ` Phil Thornley
2010-05-12 15:37                     ` Dmitry A. Kazakov
2010-05-12 16:06                       ` Yannick Duchêne (Hibou57)
2010-05-12 17:24                         ` Dmitry A. Kazakov
2010-05-12 18:09                           ` Georg Bauhaus
2010-05-12 18:33                             ` Dmitry A. Kazakov
2010-05-12 18:53                               ` Georg Bauhaus
2010-05-12 21:57                                 ` Dmitry A. Kazakov
2010-05-13  2:03                                   ` Georg Bauhaus
2010-05-13  8:39                                     ` Dmitry A. Kazakov
2010-05-14 23:45                                       ` Georg Bauhaus
2010-05-15  9:30                                         ` Dmitry A. Kazakov
2010-05-15 18:39                                           ` Georg Bauhaus
2010-05-15 20:33                                             ` Dmitry A. Kazakov
2010-05-15  0:17                             ` Robert A Duff
2010-05-15  9:40                               ` Dmitry A. Kazakov
2010-05-12 18:15                           ` Georg Bauhaus
2010-05-25 20:45                           ` Yannick Duchêne (Hibou57)
2010-05-26  7:55                             ` Dmitry A. Kazakov
2010-05-26  8:38                             ` stefan-lucks
2010-05-26  8:01                               ` Yannick Duchêne (Hibou57)
2010-05-26 11:25                               ` Yannick Duchêne (Hibou57)
2010-05-26 13:02                                 ` stefan-lucks
2010-05-26 12:22                                   ` Yannick Duchêne (Hibou57)
2010-05-27 12:47                                     ` stefan-lucks
2010-05-27 12:26                                       ` Yannick Duchêne (Hibou57)
2010-05-26 13:06                                   ` (see below)
2010-05-27 12:41                                     ` stefan-lucks
2010-05-27 12:29                                       ` Yannick Duchêne (Hibou57)
2010-05-27 15:21                                       ` (see below)
2010-06-03  3:16                                         ` Yannick Duchêne (Hibou57)
2010-06-03 10:42                                           ` Brian Drummond
2010-06-03 21:14                                             ` (see below)
2010-06-03 22:00                                               ` Britt Snodgrass
2010-06-03 22:29                                                 ` (see below)
2010-06-03 13:49                                           ` (see below)
2010-06-04 13:49                                             ` Georg Bauhaus
2010-06-04 13:53                                               ` Georg Bauhaus
2010-06-04 14:24                                               ` Yannick Duchêne (Hibou57)
2010-06-04 17:34                                                 ` Georg Bauhaus
2010-06-04 15:29                                               ` (see below)
2010-05-12 18:10                       ` stefan-lucks
2010-05-12 17:48                         ` Dmitry A. Kazakov
2010-05-13  0:37                           ` stefan-lucks
2010-05-13  9:09                             ` Dmitry A. Kazakov [this message]
2010-05-13  0:33                     ` Yannick Duchêne (Hibou57)
2010-05-10 14:15       ` GNAT Pro license (was: " Peter Hermann
2010-05-10  1:40 ` Björn Persson
2010-05-10  2:04   ` Yannick Duchêne (Hibou57)
2010-05-10  7:01     ` Ludovic Brenta
replies disabled

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