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,1888e8caa20a2f2d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Controlled types and exception safety Date: 02 Dec 2005 14:15:20 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1133550920 20601 192.74.137.71 (2 Dec 2005 19:15:20 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 2 Dec 2005 19:15:20 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6723 Date: 2005-12-02T14:15:20-05:00 List-Id: tmoran@acm.org writes: > > it's *my* responsibility to judge the tradeoffs for each case separately. > If you want "X := Y;" to leave X unchanged if there are problems during > the assignment, consider how you might handle a similar problem if you were > copying an important file on disk. You would probably do something like > rename X -> X.bak > copy Y -> X > delete X.bak > so that if their was a failure during copy you could still retrieve the > file's data. How about doing something similar for the stack object? > type stack is ... > backup_copy : access stack; > Finalize then makes a backup copy (perhaps just by swapping pointers > around), which Adjust then deletes when it successfuly finishes, or which > Adjust's exception handler uses to restore X if there's a problem. > Finalize also puts the backup_copy, with a "delete after time T" time > marker, on a queue for later garbage collection if this is a "terminal" > Finalize - analogous to a nightly "delete *.bak". But X := Y overwrites X before calling Adjust on it, so you can't store the backup copy, or any way of accessing the backup copy, in X. - Bob