comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Safety of the Booch Ada 95 Components
Date: 1999/12/14
Date: 1999-12-14T00:00:00+00:00	[thread overview]
Message-ID: <3855e866_3@news1.prserv.net> (raw)
In-Reply-To: t7g0x64nw6.fsf@calumny.jyacc.com

In article <t7g0x64nw6.fsf@calumny.jyacc.com> , Hyman Rosen 
<hymie@prolifics.com>  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"




  parent reply	other threads:[~1999-12-14  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-10  0:00 Safety of the Booch Ada 95 Components Harry Erwin
1999-12-10  0:00 ` Simon Wright
1999-12-12  0:00   ` Simon Wright
1999-12-12  0:00     ` Matthew Heaney
1999-12-12  0:00   ` Harry Erwin
1999-12-13  0:00     ` Simon Wright
1999-12-10  0:00 ` Matthew Heaney
1999-12-10  0:00   ` Harry Erwin
1999-12-12  0:00     ` Simon Wright
1999-12-12  0:00       ` Harry Erwin
1999-12-13  0:00         ` Simon Wright
1999-12-10  0:00   ` Hyman Rosen
1999-12-10  0:00     ` Harry Erwin
1999-12-10  0:00     ` Matthew Heaney
1999-12-11  0:00       ` Harry Erwin
1999-12-12  0:00         ` Robert Dewar
1999-12-12  0:00           ` Harry Erwin
1999-12-13  0:00           ` Kent Paul Dolan
1999-12-13  0:00             ` Robert I. Eachus
1999-12-13  0:00             ` Ted Dennison
1999-12-13  0:00             ` Simon Wright
1999-12-13  0:00       ` Hyman Rosen
1999-12-13  0:00         ` Robert I. Eachus
1999-12-14  0:00           ` Simon Wright
1999-12-15  0:00             ` Harry Erwin
1999-12-15  0:00             ` Mats Weber
1999-12-17  0:00               ` Simon Wright
1999-12-14  0:00         ` Matthew Heaney [this message]
1999-12-13  0:00 ` Tucker Taft
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox