comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <see.reply.to@maps.futureapps.de>
Subject: Re: Ensuring postconditions in the face of exceptions
Date: Sat, 13 Mar 2010 19:33:55 +0000
Date: 2010-03-13T19:33:55+01:00	[thread overview]
Message-ID: <4b9bda93$0$6575$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <ruqub2y84rqj.179q01lxzgatj$.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> On Fri, 12 Mar 2010 01:13:45 -0800 (PST), Ludovic Brenta wrote:
> 
>> Consider the procedure:
>>
>> type T is private; -- completion elided
>>
>> generic
>>    with procedure Visit (Object : in out T);
>> procedure Refresh (Object : in out T; Dirty : in out T) is
>> begin
>>    if Dirty then
>>       Visit (Object);
>>       Dirty := False;
>>    end if;
>> exception
>>    when others =>
>>       Dirty := True; -- warnings here
>>       raise;
>> end Refresh;
> 
> Poor design IMO. Either Dirty is a property of the object, then it must be 
> a member of T. Otherwise it is a result of Refresh for the caller, who 
> don't need Dirty flag anyway, because when exception propagates, he knows 
> that something was wrong.

Agree.  Reminds me of a "rescue clause" as in Eiffel DbC that
you use IFF trying to remove the cause of the previous exception
and then trying the subp/block again. If there is no need to retry and
you just record some state in Dirty, then why raise?  OTOH, if the
caller needs to be informed about the nature of the exception,
that information could be part of a suitably defined state parameter.



  parent reply	other threads:[~2010-03-13 19:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12  9:13 Ensuring postconditions in the face of exceptions Ludovic Brenta
2010-03-12  9:24 ` Ludovic Brenta
2010-03-12  9:29 ` Niklas Holsti
2010-03-12 11:08   ` Ludovic Brenta
2010-03-12 14:00     ` Jeffrey R. Carter
2010-03-13  3:15       ` Randy Brukardt
2010-03-13 15:14         ` Robert A Duff
2010-03-16  3:13           ` Randy Brukardt
2010-03-16 15:18             ` Robert A Duff
2010-03-16 19:00               ` Adam Beneschan
2010-03-16 20:04                 ` Robert A Duff
2010-03-16 23:23               ` Randy Brukardt
2010-03-13 17:34         ` Jeffrey R. Carter
2010-03-13  7:54 ` Stephen Leake
     [not found] ` <ruqub2y84rqj.179q01lxzgatj$.dlg@40tude.net>
2010-03-13 19:33   ` Georg Bauhaus [this message]
2010-03-14 14:05 ` Alex Mentis
2010-03-14 14:21   ` Ludovic Brenta
2010-03-14 15:12     ` Alex Mentis
2010-03-15  9:14       ` Ludovic Brenta
2010-03-15 11:05         ` cjpsimon
2010-03-15 13:04           ` Ludovic Brenta
2010-03-15 14:16             ` J-P. Rosen
2010-03-15 19:14         ` Jeffrey R. Carter
2010-03-16 19:25           ` Robert Matthews
2010-03-14 15:38     ` Robert A Duff
2010-03-15  8:54       ` Ludovic Brenta
2010-03-15 16:44         ` Robert A Duff
2010-03-15 17:33           ` Ludovic Brenta
2010-03-15 18:36             ` Robert A Duff
2010-03-14 18:57     ` Jeffrey R. Carter
2010-03-15  8:56       ` Ludovic Brenta
2010-03-15 11:04 ` AdaMagica
replies disabled

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