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: "Matthew Heaney" Subject: Re: Safety of the Booch Ada 95 Components Date: 1999/12/14 Message-ID: <3855e866_3@news1.prserv.net>#1/1 X-Deja-AN: 560426672 Content-transfer-encoding: 7bit References: <1e2lds4.7trgj21rgj9i0N%herwin@gmu.edu> <38512921_3@news1.prserv.net> <3851c7b9_4@news1.prserv.net> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 14 Dec 1999 06:49:10 GMT, 129.37.62.192 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c++ Date: 1999-12-14T00:00:00+00:00 List-Id: In article , Hyman Rosen wrote: >> If you don't like that, then don't give me a broken assignment operator. > > Why is an assignment operator that raises an exception broken? Perhaps the case is better stated in terms of the postcondition of the copy. If item assignment raises an exception during a copy of a data structure (which contains zero or more items), then 1) You can implement Copy without handling item assignment errors. This is the most efficient way to implement copy, but it will leave the target data structure in an unknown state. 2) You can implement Copy so that if item assignment raises an exception, then the target data structure is cleared or only a partial copy. This is slightly less efficient than (1) -- unless your compiler implements zero-cost exception handlers -- but it has the virtue of guaranteeing the target state. 3) You can implement Copy so that if assignment raises an exception, then the target data structure is rolled back to its original state prior to the call. This is much less efficient than (1), but has the virtue of leaving target state unchanged. So take your pick. As with all system design problems, there is no such thing as a free lunch, and you're going to have to live with some compromise. -- It is impossible to feel great confidence in a negative theory which has always rested its main support on the weak points of its opponent. Joseph Needham, "A Mechanistic Criticism of Vitalism"