From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c80e6f742e73478f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Tue, 16 Mar 2010 14:25:34 -0500 Newsgroups: comp.lang.ada Followup-To: comp.lang.ada From: Robert Matthews Subject: Re: Ensuring postconditions in the face of exceptions Date: Tue, 16 Mar 2010 19:25:34 +0000 References: <820d96c0-5d67-4b8c-8c5b-811ca4f1127e@g26g2000yqn.googlegroups.com> <8990d686-f703-4e9c-91b7-32410289983d@g11g2000yqe.googlegroups.com> <87ljdv56gy.fsf@ludovic-brenta.org> <5f3f45c6-0202-4a67-8517-182afaf7dceb@c16g2000yqd.googlegroups.com> <3782da9f-3f92-455e-ac1c-7cab721fc4df@d2g2000yqa.googlegroups.com> User-Agent: KNode/4.3.2 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Message-ID: X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-bbuWjcNcZM/wiMO8os2mJWbEWGhhJNyCmmOMO0AAxOd6A8erw7o/pi6kW/DLUALmHwTC0BG3y+Z/e7S!tOlz2PDfQMz/6qha2in/SkGAHYqNMGkuWJjpyGrp5jJcRjGeVe9Upa7m8J3421aaSwg3g0Ma9mwL!KKNWNR62OX1Nm/l5TsjylEp1 X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: g2news2.google.com comp.lang.ada:10570 Date: 2010-03-16T19:25:34+00:00 List-Id: Jeffrey R. Carter wrote: > Ludovic Brenta wrote: >> >> The problem with that approach is that the processing of the Dirty >> flag is no longer localized in the Refresh procedure which, in fact, >> might as well disappear altogether; instead, each caller of Refresh >> (or Visit) must now remember to handle exceptions and reset Dirty to >> True accordingly. > > With your code, the only way an exception can be raised is if the input > value of Dirty is True. Since Dirty is not a parameter of Visit, the call > to Visit presumably doesn't change Dirty. If so, you could eliminate the > exception handler and have the desired functionality: Dirty would be True > on return if there were an exception, and False if there were not. I think > this was mentioned before. Is there a reason this is not acceptable? > By which I presume the code could be: generic with procedure Visit (Object : in out T); procedure Refresh (Object : in out T; Dirty : in out Boolean) is begin if Dirty then Visit (Object); Dirty := False; end if; end Refresh; Looks to be the simplest approach to me, though Bob Duff's suggestion of a Cache type may be a better abstraction. Robert Matthews