After some Googling, I found out a similar technique already exists: auto_buffer in C++. http://goo.gl/3RLK6 I think it would be perfect to make it the default allocation method in D.