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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews.google.com!r29g2000hsg.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Allocators and exceptions Date: Mon, 10 Sep 2007 14:48:56 -0700 Organization: http://groups.google.com Message-ID: <1189460936.295604.143720@r29g2000hsg.googlegroups.com> References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> <1189369871.672082.162750@50g2000hsm.googlegroups.com> NNTP-Posting-Host: 85.3.208.198 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1189460936 1133 127.0.0.1 (10 Sep 2007 21:48:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 10 Sep 2007 21:48:56 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: r29g2000hsg.googlegroups.com; posting-host=85.3.208.198; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1868 Date: 2007-09-10T14:48:56-07:00 List-Id: On 10 Wrz, 14:42, "Dmitry A. Kazakov" wrote: > The question is not only about deallocation, it is also about finalization > of the components initialized before the initialization raised an > exception. Right. > Components are initialized in an arbitrary order. Oops. > I cannot tell for sure, but I guess that your example is a bounded error. > But you should really ask a language lawyer. I hoped that c.l.a. is a good place for this. > > P.S. Exceptions in constructors is a bad idea. No, it's a very good idea. Otherwise you have to deal with half-baked objects, which is Even Bigger Mess (tm). > Consider this: > > type T (Init : Integer) is record > B : access Positive := new Positive; > C : Positive := Positive (Init); > end record; > > Ptr := new T (-5); > > Now you might really want the compiler not to deallocate Ptr, so that you > were able to free Ptr.B before. But where do you know that B was > initialized? It's not my business. The compiler knows for sure what what already initialized and can therefore take the informed decision on what to roll back. I'm surprised by this issue. Really. -- Maciej Sobczak http://www.msobczak.com/