comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Unchecked_Deallocation vs. delete
Date: Fri, 11 May 2007 09:35:40 +0200
Date: 2007-05-11T09:33:57+02:00	[thread overview]
Message-ID: <brqynpyan2fg$.1rckp7j79on2$.dlg@40tude.net> (raw)
In-Reply-To: 1178827771.416316.210790@y80g2000hsf.googlegroups.com

On 10 May 2007 13:09:31 -0700, Maciej Sobczak wrote:

> On 9 Maj, 19:02, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> 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



  reply	other threads:[~2007-05-11  7:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-09 16:27 Unchecked_Deallocation vs. delete Maciej Sobczak
2007-05-09 17:02 ` Dmitry A. Kazakov
2007-05-09 20:56   ` Robert A Duff
2007-05-09 20:59   ` Keith Thompson
2007-05-10 20:09   ` Maciej Sobczak
2007-05-11  7:35     ` Dmitry A. Kazakov [this message]
2007-05-11  8:15       ` Maciej Sobczak
2007-05-11 16:39         ` Dmitry A. Kazakov
2007-05-16 19:25         ` Randy Brukardt
2007-05-10 21:10   ` Markus E Leypold
2007-05-09 17:51 ` Martin Krischik
2007-05-09 20:54 ` Robert A Duff
replies disabled

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