Disadvantages of building a compiler and library on top of a specific memory management scheme

Namespace rswhite4 at googlemail.com
Thu Feb 6 10:41:24 PST 2014


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.


More information about the Digitalmars-d mailing list