On Friday, July 27, 2012 04:27:36 Stuart wrote: > On Friday, 27 July 2012 at 02:13:19 UTC, Jonathan M Davis wrote: > > It's inherently unsafe. What happens if you returned a > > reference to foo from someFunc? > > Good answer. I didn't think of that. > > > scope on local variables is going away for pretty much the same > > reason that delete is. > > Delete is going away too? Damn. Then again, I guess I'm still > thinking in C++ terms. I need to stop doing that. > > I'm having difficulty thinking in terms of D. It looks like C++, > it compiles to native code (unlike .NET), therefore I need to > manage memory myself... ;) > > I'll get the hang of it eventually.
In general, you should just let the GC do its thing. Then when you have portions of your code that need to be optimized, _then_ you worry about managing GC memory or using malloc and free instead or whatever it takes to make it properly efficient. Coding in a way that reduces unnecessary heap allocations is also good, but if you're worrying about when you need to free GC-allocated resources, then you're likely going about things wrong, since that's what the GC is for. - Jonathan M Davis