How will std.allocator change how we program in D?
Rikki Cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Oct 3 02:40:13 PDT 2015
On 03/10/15 12:54 PM, Taylor Hillegeist 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.
All of my code here uses it: https://github.com/rikkimax/alphaPhobos
With any luck it will all be destined for Phobos.
The biggest set of changes is visible with the image library and URI.
https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/uri.d
You care far more about not allocating because of it. Atleast that was
my goal.
Something I'm definitely recently started getting into is ref counting.
https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/platform.d#L16
So both the memory can be exposed and deallocated when it is no longer used.
But generally you won't care one bit about allocators.
https://github.com/rikkimax/alphaPhobos/blob/master/source/app.d#L39
The only reason you need to care is if you want a very specific set of
life time of all memory created in a api and know/care when it dies.
Also if you got some clever way to allocate, too would matter.
But this may be different for somebody else. It is just my limited
experience.
More information about the Digitalmars-d-learn
mailing list