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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.volia.net!news.germany.com!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Controlled types and exception safety Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <8sKdnXNeIZMxIg3eRVn-ig@comcast.com> <3trncoj4t0va.19bs46zhm4xbe.dlg@40tude.net> <2Rklf.171$n1.114@newsread2.news.pas.earthlink.net> Date: Tue, 6 Dec 2005 22:20:18 +0100 Message-ID: <13xang4fkhnjw.g2203e2pgmv8$.dlg@40tude.net> NNTP-Posting-Date: 06 Dec 2005 22:20:10 MET NNTP-Posting-Host: ea85f0aa.newsread2.arcor-online.net X-Trace: DXC=D@oP^0d@>m[BJG3c^A]i\ZQ5U85hF6f;TjW\KbG]kaMXn6A=Y6OiEaTWeQLd\\UXhVWRXZ37ga[7ZjTA67ckJ=XU1EEj^WiaRZX X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:6756 Date: 2005-12-06T22:20:10+01:00 List-Id: On Tue, 6 Dec 2005 13:34:29 -0600, Randy Brukardt wrote: > This was the original idea for Ada 95, but it doesn't work. That's because > the object on the left-hand side may come into existence because of the > outer assignment, or disappear because of the assignment. The beauty (and > curse) of Adjust is that it can be called by itself when needed, or with an > appropriate Finalize. > > You can't, in general, read the object that you're assigning into. That > means that user-defined assignment in Ada can never be as powerful as that > in other languages (unless you somehow prevent the types from being used in > discriminant-dependent components - which would probably be a generic > contract problem). > > For an another explanation of this, see ARM 7.6(17.a-17.h). > http://www.adaic.com/standards/95aarm/html/AA-A-5-3.html > > The other issues are solveable, but this one is not. The question is at which cost. We could consider assignment composed out of two components. For any type T: type T'Assignment_Data is tagged limited null record; -- predefined and can be extended function T'Preassign (Left : in out T; Right : T) return T'Assignment_Data'Class; procedure T'Postassign (Left : in out T; Right : T; Data : T'Assignment_Data'Class); First T'Preassign is called. It can look at the left side, back up everything it needs in the result. It could even make rendezvous with the task components of Left, which is impossible now. Then the left side is finalized, the discriminants and constraints are set to ones of Right, some components are constructed and T'Postassign is called. Its parameter Data carries what T'Preassign has returned. After completion of T'Postassign Data is destroyed. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de