Eliminate class allocators and deallocators?

Jeremie Pelletier jeremiep at gmail.com
Thu Oct 8 09:01:20 PDT 2009


Andrei Alexandrescu wrote:
> Jeremie Pelletier wrote:
>> Yeah I agree now after reading most of this thread, I know that these 
>> keywords just map to functions.
>>
>> I've seen a proposal of a global new template somewhere, I don't like 
>> that since at the global scope there are also structs, arrays and 
>> whatnot that can be allocated by 'new'.
> 
> Well it's easy to handle all of those with conditional templates.
> 
>> I don't like the static new either since it prevents subclasses from 
>> overriding their new/delete operations.
>>
>> What would then be a good way to replace new/delete operators to still 
>> have them overridable? Isn't that the convenience that first got them 
>> to be used in the first place? Other than global new/delete overrides 
>> which is plain silly in D.
>>
>> I've pretty much found alternatives to all my other points against 
>> taking out new/delete except for the override feature, find me an 
>> alternative for that too and I'll be voting for new/delete to be 
>> runtime function instead of language keywords, cause I can't think of 
>> anything right now.
> 
> I think you'd find this article interesting:
> 
> http://www.ddj.com/article/printableArticle.jhtml?articleID=184405016&dept_url=/java/ 
> 
> 
> 
> Andrei

That was a long read, but a most interesting one! I already was familiar 
of these design pattens but only used them where new didn't make sense, 
this article really was an eye opener on that level, thanks a lot!

You have my vote to remove new/delete now :)



More information about the Digitalmars-d mailing list