eliminate new operator paraphernalia

Nick Sabalausky a at a.a
Sun Feb 14 13:06:10 PST 2010


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:hl9n50$2f9v$1 at digitalmars.com...
>
> There are many problems with custom allocators. They hook the syntax and 
> do something that's unbecoming. new T must place T on the 
> garbage-collected heap, period. That gives the guarantee that the object 
> has infinite lifetime and therefore dependable behavior. If the same 
> syntax can be used to implement various other semantics, you can't count 
> on anything in generic code.
>

Sounds to me like the exact same argument for eliminating operator 
overloading: "If we allow it, then someone could hijack '+' to do something 
unbecoming and then you can't count on anything in generic code". Generic 
code (at least in D) naturally comes with a risk of duckiness.

The whole point of custom allocators is to allow something to get the same 
result (get a new instance) through a different implementation. And as for 
the infinite lifetime guarantee: I don't think I see any risk of a 
custom-allocated object getting yanked out from under generic code unless 
you did something *really* bizarre and obviouly pointless like lauch a 
thread that randomly marks elements in an object pool as unused. 





More information about the Digitalmars-d mailing list