On Friday, October 02, 2015 23:54:15 Taylor Hillegeist via Digitalmars-d-learn wrote: > I do not come from a c++ background. but have looked at what > allocators do for c++. I know in D the standard for memory > management is garbage collection and if we want to manage it > ourselfs we have to do things like @nogc. I was just curious how > the std allocator will change how we do things.
That's very much an open question. It's too early to tell, I think. Another major factor is that Walter and Andrei are considering adding some kind of reference counting to the language (not ARC, I don't think, and it won't be required - just in addition to what we have now), and that would have a big impact on this sort of thing as well. I fully expect that exceptions will eventually be reference-counted, and it may become normal for them not to be GC-allocated as a result. But we'll have to wait and see. Another issue is std.container (or probably std.collections ultimately, since it's being redone, and we don't want to conflict with what's currently there), since that will end up using the allocators, and the impact of that could be far-reaching. For many programs, it'll probably be the only place that allocators get used though, simply because many folks are likely to just not worry that much about the GC and memory management until it actually becomes a problem for them. The folks that have stricter performance requirements will likely start using the allocators quite a bit though. Certainly, now that we have std.experimental.allocator, more code is going to be written which tries to avoid the GC, and as that's done, I expect that more idioms will come of it. The way that the allocators have been written is somewhat novel and unique, but I don't know how much that will affect their usage. In the long run though, I suspect that allocators will get used in D more than they're typically used in C++ - if nothing else because the GC is the default in D, and plenty of folks want to avoid the GC whether they actually need to or not, whereas C++'s default is manual memory management. - Jonathan M Davis
