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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,8acd4291c317f897 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,8acd4291c317f897 X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: Safety of the Booch Ada 95 Components Date: 1999/12/13 Message-ID: #1/1 X-Deja-AN: 560260244 X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 References: <1e2lds4.7trgj21rgj9i0N%herwin@gmu.edu> <38512921_3@news1.prserv.net> <1e2lkpj.jfhkndlca1p6N%herwin@gmu.edu> <1e2pka4.nppns21okbh5cN%herwin@gmu.edu> X-Trace: news.demon.co.uk 945121740 nnrp-01:11362 NO-IDENT pogner.demon.co.uk:158.152.70.98 Organization: At Home Newsgroups: comp.lang.ada,comp.lang.c++ X-Complaints-To: abuse@demon.net Date: 1999-12-13T00:00:00+00:00 List-Id: herwin@gmu.edu (Harry Erwin) writes: > Simon Wright wrote: [...] > > > Apparently in the Booch components, if the copy goes bad, the To > > > container has been cleared and is partially written. Basic exception > > > safety (== the container is still useable) is probably supported. > > > > Yes, this is the case for the Copy operation (which is *not* the > > standard assignment operation!). > > What is the standard assignment operation, then? I'm new to Ada 95. In > C++ 99, we rarely trust the compiler-defined default versions of copy > constructors and assignment operations, because they do bit-by-bit > copies. The standard Ada assignment operation is := However, it's not an operation that you have control over in the way that C++ gives you with operator=. What you do have is Controlled types (types that inherit from Ada.Finalization.Controlled). >From ALRM, 7.6 User-Defined Assignment and Finalization (1) Three kinds of actions are fundamental to the manipulation of objects: initialization, finalization, and assignment. Every object is initialized, either explicitly or by default, after being created (for example, by an object_declaration or allocator). Every object is finalized before being destroyed (for example, by leaving a subprogram_body containing an object_declaration, or by a call to an instance of Unchecked_Deallocation). An assignment operation is used as part of assignment_statements, explicit initialization, parameter passing, and other operations. (2) Default definitions for these three fundamental operations are provided by the language, but a controlled type gives the user additional control over parts of these operations. In particular, the user can define, for a controlled type, an Initialize procedure which is invoked immediately after the normal default initialization of a controlled object, a Finalize procedure which is invoked immediately before finalization of any of the components of a controlled object, and an Adjust procedure which is invoked as the last step of an assignment to a (nonlimited) controlled object. [...] (17) For an assignment_statement, after the name and expression have been evaluated, and any conversion (including constraint checking) has been done, an anonymous object is created, and the value is assigned into it; that is, the assignment operation is applied. (Assignment includes value adjustment.) The target of the assignment_statement is then finalized. The value of the anonymous object is then assigned into the target of the assignment_statement. Finally, the anonymous object is finalized. As explained below, the implementation may eliminate the intermediate anonymous object, so this description subsumes the one given in 5.2, ``Assignment Statements''. I don't think there's a web version of the ALRM at www.adapower.com. There is one at www.adahome.com (no longer maintained, it seems, but still with goodies like this).