More radical ideas about gc and reference counting

via Digitalmars-d digitalmars-d at puremagic.com
Sun May 11 03:43:59 PDT 2014


On Sunday, 11 May 2014 at 09:53:59 UTC, Manu via Digitalmars-d 
wrote:
> On 11 May 2014 17:52, Benjamin Thaut via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> Am 06.05.2014 05:40, schrieb Manu via Digitalmars-d:
>>
>>> I support the notion that if the GC isn't removed as a 
>>> foundational
>>> feature of D, then destructors should probably be removed 
>>> from D.
>>>
>>> That said, I really want my destructors, and would be very 
>>> upset to
>>> see them go. So... ARC?
>>>
>>
>> I think ARC could work, but should be extended with some sort 
>> of ownership
>> notation. Often a block of memory (e.g. an array of data) is 
>> exclusivly
>> owned by a single object. So it would be absolutly uneccessary 
>> to reference
>> count that block of memory. Instead I would want something 
>> like Rust has,
>> borrowed pointers. (We actually already have that, "scope" but 
>> its not
>> defined nor implemented for anything but delegates)
>
> Indeed, I also imagine that implementation of 'scope' would 
> allow for
> a really decent ARC experience. D already has some advantages 
> over
> other languages, but that one would be big.

Yes, together with an opImplicitCast of some sort it could 
probably even be implemented as a pure library type 
(std.typecons.RefCounted). std.typecons.scoped can also benefit 
from this.

This would allow safe implicit casting to non-RC types, i.e. 
passing to a function that accepts a non-RC scope parameter. This 
is extremely important if we want to be able to use RC types only 
in some cases; otherwise it would need to "infect" everything in 
order to be safe.


More information about the Digitalmars-d mailing list