Discussion about D at a C++ forum

Steven Schveighoffer schveiguy at yahoo.com
Mon Jan 9 07:00:09 PST 2012


On Mon, 09 Jan 2012 09:47:13 -0500, Zachary Lund <admin at computerquip.com>  
wrote:

> On 01/09/2012 07:58 AM, Steven Schveighoffer wrote:
>> On Sun, 08 Jan 2012 18:28:54 -0500, Mehrdad <wfunction at hotmail.com>  
>> wrote:
>>
>>> 7. Unstable language. They're currently considering doing things like
>>> removing "delete" as it's apparently deprecated (which will officially
>>> make it not usable as an SP language).
>>> Looks 100% correct. Removing 'delete' /does/ make D unusable as an SP
>>> language... unless you ignore the GC completely, which isn't even
>>> possible, practically speaking.
>>
>> C doesn't have delete.
>>
>> But removing delete isn't the problem anyways. Here is the problem
>> (which exists with delete present in the language):
>>
>> class C
>> {
>> private int[] buf;
>> this() { buf = new int[5]; }
>> ~this() {/* can't destroy buf here */}
>> }
>>
>> void main()
>> {
>> auto c = new C;
>> delete c; // doesn't destroy c.buf
>> }
>>
>> What we need is a way to hook deterministic destruction vs. GC
>> destruction. Only then, a SP language will you be.
>>
>> -Steve
>
> I was under the impression you could overload new and delete per  
> class/union/struct which gave you the ability to control how things were  
> allocated.

Currently, but scheduled for deprecation (to be replaced by existing  
library solutions).  But it's not good enough anyways.  If I want to use  
the GC to allocate my buffer, I still must rely on the GC to destroy it,  
even if I destroy my class deterministically.  Using an allocator won't  
fix that.

-Steve


More information about the Digitalmars-d mailing list