Phobos addition formal review: std.experimental.allocator

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 21 04:47:11 PDT 2015


Ok, as there has not been much attention here in last days, I 
will put a short summary of my own.

In general, I believe this is extremely high quality proposal and 
Andrei stands up to his reputation. The very design seems to fit 
with D idiomatics and it may change completely how people think 
about interaction with allocator library. I like that is focuses 
on robust API for building allocators instead of more "magic" to 
use those. That said, reviewing actual implementation quality is 
impossible until I have a chance to try it in real large scale 
project and I will not be trying to do that, assuming that Andrei 
is incapable of writing something completely terrible even if he 
tried to.

Pretty much all of my concerns are about documentation, API and 
clarity of intention. Quality of implementation won't matter if 
developers won't have a clear understanding on how to use it and 
existing proposals feels overwhelming unless one is willing to 
commit quite some time to research it.

Some notes:

1. I have already mentioned that there is neither module 
structure overview in `package.d` nor actual module structure. 
This is still the case for 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator.html
2. `IAllocator` is defined inside `package.d` file. That means 
that it is impossible to use interface without import ALL of 
allocator modules
3. Same concern is about 
https://github.com/andralex/phobos/blob/allocator/std/experimental/allocator/package.d#L218-L228 - unless you actually import all stuff via package.d, those configured allocators are not available.
4. There are no higher level usage examples and/or guidelines 
about how this is supposed to fit in user applications. Intention 
behind the library may be familiar to users coming from C++ but 
target D audience is much more than that. Having 
std.allocator.showcase is nice but it is still a bit too 
theoretical.
5. 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_stats_collector.html has no overview documentation at all
6. Usage of ternary is not always clear / justified. In 
`IAllocator` it is explained and makes sense but there are things 
like 
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_bitmapped_block.html ("Ternary empty() - Returns true iff no memory is currently allocated with this allocator"). I am still not sure why it is used there instead of simple boolean.

Overall opinion : I would surely vote for inclusion of this 
proposal in Phobos but in current shape it is not something I'd 
recommend to try to beginner/intermediate level D user.


More information about the Digitalmars-d mailing list