@nogc and NSAutoReleasePool-style regions.
via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 8 13:38:58 PDT 2014
A custom allocator can also be specified. The nice thing is, that
this doesn't even need new syntax:
process(A a) {
int x;
{
MyCustomAllocator alloc;
GC.pushAllocator(alloc);
scope(exit) GC.popAllocator();
auto y = new ...;
// alloc's destructor is called, which calls destructors
of
// allocated objects
}
}
But as you already noted, there needs to be a mechanism to
restrict escaping of pointers. Do you have some concrete idea how
that could be solved? A more or less straight-forward way would
be to encode the ownership/lifetime information somewhere in the
types of the pointers (similar to how we use const and the like
today). But this cannot be done, because it could not apply to
external (non-template) functions.
More information about the Digitalmars-d
mailing list