I like the idea, but instead of new!strategy I would prefer:
use @strategy(RefCount)
or
use @strategy(GC) // Default

We would have in druntime some functions which are tagged with @strategy(Whatever) (which are invoked if the use comes):
----
@strategy(C_Memory)
T[] new(T : U[], U)(size_t count) {
        return (cast(U*) calloc(count, T.sizeof))[0 .. count];
}

@strategy(C_Memory)
void delete(T : U[], U)(ref U[] arr) {
        free(arr.ptr);
        arr = null;
}
----

It's not perfect, just a thought.

Reply via email to