comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: and then... (a curiosity)
Date: Fri, 05 Sep 2008 09:57:29 -0400
Date: 2008-09-05T09:57:29-04:00	[thread overview]
Message-ID: <wcc7i9qsnjq.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: Pine.LNX.4.64.0809050904150.27752@medsec1.medien.uni-weimar.de

stefan-lucks@see-the.signature writes:

> On Thu, 4 Sep 2008,  wrote:
>
>> > Very strange that the Ada compiler is able to compile stuff if you write
>> > "and then" instead of "and". Following your point, the designers of Ada
>> > did overestimate the smartness of compilers. ;-)
>> 
>> My objections are targeted at the thing that you propose (elsewhere called
>> 1+2). That beast would either allow bugs to hide, or would require whole
>> program analysis and perhaps mind-reading capabilties.
>
> Firstly, I have been very clear that I didn't "propose" that. 
>
> Secondly, it is easy to implement.

What is "it" here?  In the below, are you implementing the 1+2 idea,
or the 3 idea?  Neither one seems right (even ignoring the minor
syntax errors)...

>... Replace "if A and B then ... else ... 
> end if" by:
>
> declare 
>   T_A := A;
> begin
>   if T_A then 
>     return B; -- may raise an exception
>   end if;
> exception
>   when others =>
>     if B -- may raise an exception
>     then 
>       raise; -- propagate the exception raised by A 
>     else
>       return False;
>     end if;
> end;

In the above, if B raises an exception the first time, we evaluate B
again (and maybe it raises the exception again, or maybe not).
Surely that's not what you meant!  And the comment 
"propagate the exception raised by A" is wrong, since the
handler doesn't apply to exceptions raised by A.

> Hey, do you need mind-reading capabilities for that?

Yes, I need to read your mind to know what you meant above.  ;-)

>...I would consider 
> this an exercise for Students -- and a really easy one.;-)

;-)

> Now, a really ugly issue is that both the evaluation of A and the 
> evaluation of B might raise an exeption, and we cannot re-raise both 
> exceptions. If not for other reasons, that suffices not to propagate that. 
> Well, one could raise a Program_Error in that case, but that is ugly 
> anyway. But note that even in Ada-as-it-is, it is not defined which of 
> both exceptions is raised!

Sure, that's a little ugly, but in practice it doesn't matter -- the
fact that something went wrong is not lost.

- Bob



  parent reply	other threads:[~2008-09-05 13:57 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-29 21:06 and then... (a curiosity) mockturtle
2008-08-29 21:47 ` Samuel Tardieu
2008-08-30 21:28   ` Maciej Sobczak
2008-08-31  8:28     ` Georg Bauhaus
2008-08-31 23:21       ` Ray Blaak
2008-09-01  8:05     ` Martin Krischik
2008-09-01 17:56       ` Ray Blaak
2008-09-02  6:53         ` Martin Krischik
2008-09-02 14:56           ` Adam Beneschan
2008-09-02 16:28             ` Ray Blaak
2008-09-02 16:26           ` Ray Blaak
2008-09-02 20:50             ` Robert A Duff
2008-09-03 12:35               ` Brian Drummond
2008-09-03 15:56                 ` Robert A Duff
2008-09-04 22:09                   ` Brian Drummond
2008-09-03 21:01               ` Vinzent Hoefler
2008-09-02 14:50     ` Adam Beneschan
2008-08-29 22:28 ` Adam Beneschan
2008-08-30  1:06   ` Jeffrey R. Carter
2008-08-30 11:21   ` Dmitry A. Kazakov
2008-08-30 15:35     ` Peter C. Chapin
2008-09-02 15:06       ` Adam Beneschan
2008-09-02  3:41 ` Steve
2008-09-02  7:48   ` stefan-lucks
2008-09-02  8:57     ` Martin Krischik
2008-09-02 10:50       ` stefan-lucks
2008-09-02 10:33         ` Ludovic Brenta
2008-09-02 13:32           ` stefan-lucks
2008-09-02 12:53             ` Ludovic Brenta
2008-09-02 17:32               ` Georg Bauhaus
2008-09-03 13:14               ` stefan-lucks
2008-09-03 12:44                 ` Dmitry A. Kazakov
2008-09-02 13:39             ` stefan-lucks
2008-09-02 13:40             ` stefan-lucks
2008-09-02 16:48             ` Dmitry A. Kazakov
2008-09-02 17:00             ` Keith Thompson
2008-09-02 19:15               ` Simon Wright
2008-09-02 20:37               ` Robert A Duff
2008-09-02 20:58                 ` Jeffrey R. Carter
2008-09-02 21:08                   ` Robert A Duff
2008-09-03 12:24                     ` Pascal Obry
2008-09-02 22:34                   ` Santiago Urueña
2008-09-03  5:56                     ` Robert A Duff
2008-09-03  6:55                       ` Santiago Urueña
2008-09-03 14:14                       ` Adam Beneschan
2008-09-03  0:11                 ` Randy Brukardt
2008-09-02 17:20             ` Georg Bauhaus
2008-09-04  1:05         ` Stephen Leake
2008-09-04  6:45           ` stefan-lucks
2008-09-04  7:35             ` Dmitry A. Kazakov
2008-09-04 12:04               ` stefan-lucks
2008-09-04 13:00                 ` Dmitry A. Kazakov
2008-09-04 19:05                   ` stefan-lucks
2008-09-04 20:28                     ` Dmitry A. Kazakov
2008-09-05  6:57                       ` stefan-lucks
2008-09-05  6:34                         ` Ray Blaak
2008-09-05 14:14                     ` Robert A Duff
2008-09-05 15:04                       ` Dmitry A. Kazakov
2008-09-07 16:45                         ` stefan-lucks
2008-09-05 15:14                       ` Hyman Rosen
2008-09-05 15:59                         ` Adam Beneschan
2008-09-05 16:10                           ` Hyman Rosen
2008-09-07 16:36                       ` stefan-lucks
2008-09-07 16:08                         ` Gautier
2008-09-04  7:39             ` Karel Th�nissen
2008-09-04 12:12               ` stefan-lucks
2008-09-04 15:13                 ` Georg Bauhaus
2008-09-04 15:16                 ` Karel Th�nissen
2008-09-04 15:42                   ` Dmitry A. Kazakov
2008-09-04 19:27                   ` stefan-lucks
2008-09-04 19:43                     ` stefan-lucks
2008-09-04 19:40                       ` Georg Bauhaus
2008-09-05  7:00                         ` stefan-lucks
2008-09-05  6:35                           ` Ray Blaak
2008-09-04 20:06                       ` Karel Th�nissen
2008-09-05  7:44                         ` stefan-lucks
2008-09-05  6:41                           ` Vinzent Hoefler
2008-09-04 20:09                     ` Karel Th�nissen
2008-09-05  7:25                       ` stefan-lucks
2008-09-05  6:37                         ` Ray Blaak
2008-09-05  8:20                           ` stefan-lucks
2008-09-05 13:57                         ` Robert A Duff [this message]
2008-09-04 16:33                 ` Dmitry A. Kazakov
2008-09-04 19:31                   ` stefan-lucks
2008-09-04 19:59                     ` Karel Th�nissen
2008-09-05  7:27                       ` stefan-lucks
2008-09-05  8:38                         ` Ludovic Brenta
2008-09-04 20:17                     ` Dmitry A. Kazakov
2008-09-05 13:26                 ` Robert A Duff
2008-09-05 13:49                   ` Robert A Duff
2008-09-03  1:24     ` Stephen Leake
2008-09-03  3:31       ` tmoran
2008-09-03 13:22       ` stefan-lucks
replies disabled

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