On 09/23/2013 01:49 AM, Andrei Alexandrescu wrote:
I am making good progress on the design of std.allocator, and I am
optimistic about the way it turns out. D's introspection capabilities
really shine through, and in places the design does feel really
archetypal - e.g. "this is the essence of a freelist allocator". It's a
very good feeling. The overall inspiration comes from Berger's
HeapLayers, but D's introspection takes that pattern to a whole new level.
...
Seems neat.
Several details are still in flux, but at the top level it seems most
natural to divide things in two tiers:
1. Typed allocator, i.e. every request for allocation comes with the
exact type requested;
2. Untyped allocator - traffics exclusively in ubyte[].
...
Some general remarks:
One issue you will probably run into and maybe want to fix in some way
during the typed allocator design is that private constructors cannot be
called from templates parameterized on types.
E.g.:
module a;
auto New(T,Args...)(Args args){
return new T(args);
}
// ---
module b;
class A{
private this(){}
}
void main(){
auto a = New!A(); // error
}
Is there an intention to also support replacements of instance new
allocations, i.e. object.new subobject(args)?