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!news.ecp.fr!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:19:01 -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> <5rjahxfvhazu.bol1ilmh6uew$.dlg@40tude.net> <1189537626.913207.116840@e34g2000pro.googlegroups.com> <1189551376.12652.36.camel@kartoffel> <1189600614.629447.86470@k79g2000hse.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1189635366 27934 69.95.181.76 (12 Sep 2007 22:16:06 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 12 Sep 2007 22:16:06 +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:1924 Date: 2007-09-12T17:19:01-05:00 List-Id: "Maciej Sobczak" wrote in message news:1189600614.629447.86470@k79g2000hse.googlegroups.com... > On 12 Wrz, 00:56, Georg Bauhaus > wrote: > > > > But... did I mention that C++ handles this issue correctly? ;-) > > > And no, it does not have any super-capable access types. A little bit > > > smarter allocator is enough. > > > > C++ doesn't seem to handle deallocation etc. of sibling components > > either, so I'm not sure I understand. > > It does. In case of exception the already constructed components are > rolled back. This works for components of array as well. Ada does of course finalize any components that have already been constructed. It doesn't just drop them on the floor!! The problem (if you can call it that) with Ada is that is clearly defines when that will happen. You want it to happen *earlier* than that definition. One could argue that that definition is wrong, but it is what it is. For what it's worth, the definition you seem to want would be extremely expensive to implement in Janus/Ada: every allocated component would need a dedicated (compiler generated) exception handler in order to be able free the associated memory immediately. The effect would be to make allocators 10 times bigger and possibly 10 times slower. (It surely would be that much for our [obsolete] MS-DOS compilers, which used a heap of our own design; I'm not sure how expensive the Windows heap allocations are so it might be somewhat less.) Programs that do a lot of allocation could have a pretty significant performance impact (and that would include the containers libraries). Randy.