just to toss in my quick thoughts, I wrote a couple comments on the recent reddit thread about using D with a minimal runtime and some of the talk may be relevant here too:

http://www.reddit.com/r/programming/comments/1fc9jt/dmd_2063_the_d_programming_language_reference/ca94mek


Some little things we could do is add overloads to some functions that return string to be able to take a buffer argument too.

string to(T:string)(int a) { char[] buf = new char[](16); return assumeUnique(to(a, buffer));

char[] to(int a, char[] buffer) { deposit it straight into buffer, return the slice into buffer that is actually used; }


and so on for all kinds of functions. Kinda a pain in the butt but when you need it, you have the second variant, and if you don't care, the convenient first one is still available (also avoids breaking code!)


I also mentioned on irc yesterday that I think a good, low cost idea to help find allocations is to add a global flag to druntime that makes gc_malloc throw an Error. Then you can set this flag in a critical section of code and at least get a runtime notice of a missed allocation in testing while still having the gc for the rest of the app.

Another member also suggested you can do that easily enough by running the program in a debugger and setting a breakpoint at gc_malloc, but I think the flag would be simpler yet.

Reply via email to