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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d067a5a7c60c3b40 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Unchecked_Deallocation vs. delete Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1178728045.890171.6110@q75g2000hsh.googlegroups.com> <1hzydt9ej6az6$.12jl0su9budun.dlg@40tude.net> <1178827771.416316.210790@y80g2000hsf.googlegroups.com> Date: Fri, 11 May 2007 09:35:40 +0200 Message-ID: NNTP-Posting-Date: 11 May 2007 09:33:57 CEST NNTP-Posting-Host: ce0e2e4a.newsspool2.arcor-online.net X-Trace: DXC=>E6_o[:RDEHlU`@c^jLCbJA9EHlD;3YcB4Fo<]lROoRA8kFOF50FQ\e2]XM X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15747 Date: 2007-05-11T09:33:57+02:00 List-Id: On 10 May 2007 13:09:31 -0700, Maciej Sobczak wrote: > On 9 Maj, 19:02, "Dmitry A. Kazakov" > wrote: > >>> What's the benefit of Unchecked_Deallocation as a generic library >>> procedure vs. built-in deallocation operator like delete in C++? >> >> To make it harder to use. > > Why not make a > Very_Hard_To_Use_Unchecked_Deallocation_Built_In_Operator instead? Primitive operation of the access type you mean, there is no need to introduce an operator. > I'm not asking about the spelling (which is ugly for purpose), but > about category. Well, as for categories, what is the benefit of having pointers? If I designed Ada I would make referential derived types (of the target type) instead. Fully transparent, no ugly ".all", no predefined shallow assignment etc. >>> The disadvantage, as far as I perceive it, is that it breaks the >>> symmetry that should be expected with regard to the allocation >>> operation. If "new" is built-in, then the deallocation should be built- >>> in as well. >> >> The symmetry is apparent. Pointers can be constructed using two methods: >> new T and X'Access. > > Then put a run-time check in this Very_Hard_..._Operator. That might mean overhead on some architectures. > Or, why not making separate "subtypes" of pointers? Sure, I am with you. With the storage pool considered a discriminant of the access type, it would be easy. But look at the recent debate about discriminated types. There is no acceptance here. > One would be a > specialization of pointers for X'Access and another for new T. You > would need to use the "subtype" for new T to deallocate, or the > compiler would spank you and the downcast to this "subtype" (if ever > needed) would be a perfect place for the run-time check. > (this is a wild idea, but seems to be more in the spirit of Ada) No, IMO it is quite reasonable, but see above. >> Further even if a pointer is constructed with new, it >> can be subject of GC. > > So? GC does not prevent me from calling U_D or Very_..._Operator. My comment was about symmetry between new and free. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de