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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Controlled types and exception safety Date: Tue, 06 Dec 2005 10:00:39 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: <8sKdnXNeIZMxIg3eRVn-ig@comcast.com> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1133859639 15792 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Red Hat/1.7.12-1.1.3.2.SL3 X-Accept-Language: en-us, en In-Reply-To: <8sKdnXNeIZMxIg3eRVn-ig@comcast.com> Xref: g2news1.google.com comp.lang.ada:6744 Date: 2005-12-06T10:00:39+01:00 List-Id: tmoran@acm.org wrote: >>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. > > Right. But Adjust, in case of problems, could still find the copy of > the old X in the "to be deleted" backup queue and restore X from there. > I didn't say this was nice, just that it was possible. ;) Except that it doesn't solve anything. The whole issue with this commit-or-rollback implementation is that it should not just suppress the exception and pretend that nothing happened - it should guarantee the old state and at the same time let the exception fly out to the place where it could be actually handled, whatever that means in the given context. I've started with the assumption that function ":=" is allowed to fail - in the sense that it can raise exceptions. It's not, and therefore there is no point in implementing any failover features in it. It has to either guarantee the success or not be provided at all and the type should be limited. This brings me to the next problem. Let's say that I provide a separate procedure Duplicate or Copy or Assign or whatever with the commit-or-rollback guarantees for some type (like Stack). Now, some of the types in my program will have ":=" for assignment, and some others will have the Copy procedure, but not ":=". I want to create a generic container or some other component that will copy things around internally. It has to use ":=" for some types (like Integer) and Copy for others (like Stack). In C++ I solve this problem (aside the fact that there is no problem in the first place) with template type traits or some other application of template specializations. What about Ada? -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/