Proposal for dual memory management

Kagamin spam at here.lot
Wed Jul 28 19:43:42 PDT 2010


Petr Janda Wrote:

> > Keep in mind that this would probably also be legal code:
> > Foo f = new(alloc!Foo()) Foo();
> 
> Well I think the goal, according to Andrei, is to split allocation/construction
> and deallocation/destruction.

Allocation and construction is also split?
Then you can use unused new() argument list:
---
shared stream = File.new().ctor("/foo.d").open(O_READ); //gc heap
shared stream = File.new(heap2).ctor("/foo.d").open(O_READ); //oops, leak
shared stream = File.new(scope).ctor("/foo.d").open(O_READ); //now ok
stream.dtor().free(); //illegal, free(Heap storage) requires heap
stream.dtor().free(heap2); //throw if not found in heap2
---


More information about the Digitalmars-d mailing list