[dmd-internals] 8th Sprint Planning
Andrei Alexandrescu via dmd-internals
dmd-internals at puremagic.com
Sun Nov 1 14:42:32 PST 2015
On 11/01/2015 04:35 PM, Martin Nowak via dmd-internals wrote:
> On 10/27/2015 10:45 PM, Andrei Alexandrescu wrote:
>> Oddly enough I want to dissuade you from doing RC - per my post "Safe
>> reference counting cannot be implemented as a library" it's impossible
>> to make library-level RC safe, which decreases its interest
>> dramatically. We plan to do language-level reference counting, which, if
>> we succeed, would obviate any RC library for classes.
>>
>> However, working on uniqueness is great! We'll either see how far we can
>> get within the current language, or figure the minimal language
>> additions needed to make it work.
>
> Well unique classes also cannot be implemented safely.
There's a less pleasant possibility: have the unique object NOT offer a
pointer/reference to the held resource, but only offer a method such as
.relinquish() that destructively reads it. So:
Unique!int x = makeUnique!int(42);
int* p = x.relinquish;
assert(x.empty);
assert(*p == 42);
So... relinquish destructively gets the raw pointer from the unique
object and puts the responsibility of managing it straight on the
shoulders of the user.
> Now I think @safe reference counting is great but we don't know if or
> when any of those ideas pan out. So I'd rather implement a small dub
> package now than waiting for the ultimate solution. If that gets laters
> obsoleted by a safer and better dmd/phobos implementation, all the better.
I think that's a great route to follow. A carefully written library
implementation will inform any study
Andrei
More information about the dmd-internals
mailing list