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,6b1a1ed8b075945 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Allocators and exceptions Date: Wed, 12 Sep 2007 17:25:07 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> <1189369871.672082.162750@50g2000hsm.googlegroups.com> <1189460936.295604.143720@r29g2000hsg.googlegroups.com> <1189502377.626510.172690@22g2000hsm.googlegroups.com> <1189601170.835400.72630@w3g2000hsg.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1189635732 28202 69.95.181.76 (12 Sep 2007 22:22:12 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 12 Sep 2007 22:22:12 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:1925 Date: 2007-09-12T17:25:07-05:00 List-Id: "Maciej Sobczak" wrote in message news:1189601170.835400.72630@w3g2000hsg.googlegroups.com... > On 12 Wrz, 14:29, Stephen Leake > wrote: > > > The rule should be: > > > > Constructors should not propagate exceptions up; they must handle > > all exceptions internally. > > No. > What should the constructor do *after* handling the exception? > Leave the object half-baked? No, unbaked. > Do you want to introduce additional states to the object design just > to handle the "oops I'm not initialized" case? No, because you must have those states anyway. Ada allows an object to be finalized multiple times (either by an explicit call to Finalize, or in some obscure cases involving aborts), so you have to have an invalid (not between initialization and finalization) state in any Ada controlled object. (Blindly doubly finalizing an object is likely to be a serious bug, because of calling Unchecked_Deallocation twice on the same object or similar gaffes.) Any controlled type that doesn't have an "I'm not valid" state is wrong, period. Once you have such a state, having an uninitialized object is not a disaster. Randy.