std.allocator needs your help
Johannes Pfau
nospam at example.com
Mon Sep 23 09:50:34 PDT 2013
Am Mon, 23 Sep 2013 18:36:57 +0200
schrieb Andrej Mitrovic <andrej.mitrovich at gmail.com>:
> On 9/23/13, Johannes Pfau <nospam at example.com> wrote:
> > New should then be considered as deprecated and replaced by
> > create!(GCAllocator, Class)().
>
> What? That's never gonna happen. For one thing, it looks ugly as hell.
> And for another, it's going to break everything written in D.
That's why I say "considered" and not really deprecated. But if you
want to / have to write allocator aware code which can use the GC it's a
nice solution:
auto list(Payload, Allocator = GCAllocator)()
{
create!(Allocator) ...
}
Of course the API should be improved.
For example create could default to the GC allocator. Then it's
"auto a = new Class(...)" vs "auto a = create!Class(...)".
But IIRC when emplace was first implemented and class allocators were
removed it was quite clear that new could be easily replaced by a
template function and has no real place as a builtin anymore. It's just
too late to remove it.
More information about the Digitalmars-d
mailing list