On Thu, 12 Nov 2009 20:26:44 +0300, Bill Baxter <[email protected]> wrote:
2009/11/12 Denis Koroskin <[email protected]>:// untested void mkdirRecurse(string path) { char* buffer = alloca(path.length); memcpy(buffer, path); foreach (i, c; buffer[0..path.length]) { if (c == '/') { buffer[i] = 0; mkdir(buffer); buffer[i] = '/'; } } } There are a lot of functions that allocate without a clear reason.)I'm pretty sure the reason is that it means library code that's easier to write, understand and maintain. But yeh, if you give me the choice of two different functions, one that allocates and one that doesn't, otherwise identical, I'll pick the non-allocating version. --bb
It also means that the former function can't be used in programs that disable GC (kernels, embedded development etc). Quality is in the details like that.
Java/C# don't follow this rule, but they are not systems programming languages, and their GCs are a lot better that D's one.
