std.allocator needs your help
Johannes Pfau
nospam at example.com
Wed Sep 25 11:27:38 PDT 2013
Am Wed, 25 Sep 2013 17:22:28 +0200
schrieb Benjamin Thaut <code at benjamin-thaut.de>:
> Am 25.09.2013 00:39, schrieb Andrei Alexandrescu:
> >
> > We're banning that syntax of new.
> >
> > Andrei
>
> I always love it when people just plain ignore all the arguments I
> made ...
>
I think there's a misunderstanding here. new(...) already was a valid
syntax in D1, I think Andrei is referring to that:
http://www.digitalmars.com/d/1.0/class.html#allocators
And we really should get rid of that.
The nested class/context pointer argument is a pretty strong one. Of
course we could introduce builtins to deal with that but there's not
much benefit to that.
Having the compiler rewrite
"new(MallocAllocator) MyClass(a,b,c)"
to
"void[] __buf = MallocAllocator.it.allocate(MyClass.instancesize);"
"__construct!MyClass(__buf, a, b, c);" //Has to handle context ptr
seems like a good solution. It probably has to support both allocator
types(for allocators without state) and allocator instances.
More information about the Digitalmars-d
mailing list