Safe reference counting cannot be implemented as a library

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 27 11:10:12 PDT 2015


I've made the claim that we should implement reference counting 
as a library many time, so I think I should explicit my position. 
Indeed, RC require some level a compiler support to be safe. That 
being said, the support does not need to be specific to RC. On 
fact, my position is that the language should provide some basic 
mechanism on top of which safe RC can be implemented, as a 
library.

The problem at hand here is escape analysis. The compiler must be 
able to ensure that a reference doesn't escape the RC mechanism 
in an uncontrolled manner. I'd like to add such mechanism to the 
language rather than bake in reference counting, as it can be 
used to solve other problem we are facing today (@nogc exception 
for instance).



More information about the Digitalmars-d mailing list