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 Path: g2news1.google.com!news1.google.com!news.glorb.com!news.mv.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ensuring postconditions in the face of exceptions Date: Mon, 15 Mar 2010 14:36:10 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <820d96c0-5d67-4b8c-8c5b-811ca4f1127e@g26g2000yqn.googlegroups.com> <8990d686-f703-4e9c-91b7-32410289983d@g11g2000yqe.googlegroups.com> <87ljdv56gy.fsf@ludovic-brenta.org> <22728d81-9ede-4128-ab47-eacec75f6954@r27g2000yqn.googlegroups.com> <2e29400d-9fe2-467f-8858-f88f79cd4caf@a18g2000yqc.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1268678157 26013 192.74.137.71 (15 Mar 2010 18:35:57 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 15 Mar 2010 18:35:57 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:wSyTUPagg70laABNmjnIx5ZL2mQ= Xref: g2news1.google.com comp.lang.ada:9578 Date: 2010-03-15T14:36:10-04:00 List-Id: Ludovic Brenta writes: > Robert A Duff wrote on comp.lang.ada: >> Ludovic Brenta writes: >> > No, Dirty is not a property of the object; the type T is used in >> > several places, only some of which (a one-line cache, essentially) has >> > a Dirty property. >> >> OK, then Dirty is a property of the cache. �So how about: >> >> � � type Cache is limited >> � � � � record >> � � � � � � X : T; >> � � � � � � Dirty : Boolean := True; >> � � � � end record; >> � � type Cache_Ref is access all Cache; >> >> and pass a parameter of type Cache_Ref? �(Or perhaps >> X could be an access type, and point to the T object.) >> >> You need to pass some sort of pointer, explicitly or implicitly, >> because when you raise an exception, the copy-back is skipped. >> You said that relying on limitedness to force pass-by-referrence >> is confusing -- I agree. �So pass an explicit pointer. >> >> I recommend a named access type, because anonymous access parameters >> have dynamic accessibility, which is a tripping hazard, and is >> less efficient. > > Yes, that's the solution I have, currently, i.e. (5); except that the > Cache type already existed before, has other unrelated components and > is not limited. Right, but you said you didn't like it, because of the "other unrelated components". So the type I'm suggesting above is a different one than the existing one -- I'm suggesting this new type would NOT have the unrelated components. I haven't seen your code, of course, so I could be talking complete nonsense. ;-) - Bob