deprecated delete and manual memory management

so so at so.so
Wed Apr 27 13:53:01 PDT 2011


On Wed, 27 Apr 2011 23:42:59 +0300, Daniel Gibson <metalcaedes at gmail.com>  
wrote:

> Am 27.04.2011 22:41, schrieb Daniel Gibson:
>> Am 27.04.2011 22:37, schrieb so:
>>>> It'd create template bloat and uglier syntax (expecially confusing for
>>>> people coming from about any other popular OO language) for a really
>>>> common, standard feature.
>>>> These drawbacks are acceptable for custom allocation and other stuff  
>>>> the
>>>> average user shouldn't care about, but not for an elemental feature  
>>>> like
>>>> "new".
>>>>
>>>> Cheers,
>>>> - Daniel
>>>
>>> For the template bloat, yes that would be a problem.
>>> But it is not ugly! Take it back! :)
>>>
>>> auto a = new A;
>>> auto a = new!A();
>>>
>>> auto b = new B(5);
>>> auto b = new!B(5);
>>>
>>> For the confusion part, the real confusion (rather shock) awaits when
>>> they get to the part where they see "new" but no "delete".
>>> We could argue against this all the way, but to every single of us  
>>> "new"
>>> and "delete" are a pair.
>>
>> No, in Java and C# there's no delete.
>
> Also, new (== creating a new Object on the heap) is a standard feature
> in D that is needed all the time, delete (== manually destroy and
> deallocate an Object) isn't.

As Steven also pointed out:
> For non-garbage-collected languages, yes.  For GC languages, delete is  
> to be discouraged (that is what the GC is for)

Which makes D special, since it claims it can do both. One would expect it  
to work as it advertised, without writing a whole runtime of your own.


More information about the Digitalmars-d mailing list