Phobos 3 Discussion Notes - 02-01-2024
Paul Backus
snarwin at gmail.com
Wed Feb 7 16:38:38 UTC 2024
On Wednesday, 7 February 2024 at 11:46:11 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> My conclusion was that you really only have two use cases for
> composable allocators:
>
> 1. You know about memory patterns, locking, type sizes ext. Use
> composable directly.
> 2. Otherwise, use virtual.
>
> There doesn't seem to be anything in between.
The relevant constraint here isn't composability, it's safety.
In order to make allocators @safe (which is the goal of my
proposal), you have to guarantee somehow that memory blocks can
only be deallocated by the same allocator that originally
allocated them.
It is possible to do this with a polymorphic allocator, but it
incurs an enormous amount of runtime overhead, which rules out
making it the default approach.
Of course, if you don't care about @safe, you can ignore all of
this and use a much simpler design. Personally, I think Phobos V3
should support @safe as much as possible, but ultimately that
choice is up to project leadership.
More information about the Digitalmars-d
mailing list