On Friday, 9 February 2018 at 01:36:02 UTC, Mike Franklin wrote:
On Friday, 9 February 2018 at 01:31:41 UTC, Mike Franklin wrote:
On Thursday, 8 February 2018 at 17:10:00 UTC, bachmeier wrote:

What are D's limitations on do-it-yourself reference counting?

* Types that are built into the language like dynamic arrays, associative arrays, and exceptions won't benefit from DIY reference counting. * Much of Phobos probably wouldn't be compatible with DIY reference counting.

That being said, there may be a way to override some runtime hooks like _d_newclass (https://dlang.org/library/rt/lifetime/_d_newclass.html), etc... to make it work. But I haven't tried.

Also, I think Walter is currently working on getting reference counted exceptions into the language: https://github.com/dlang/druntime/pull/1995


Also, I think DIY reference counting is already done for us in the automem library https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/


We use std.typecons.RefCounted in many places in Phobos too.
There is only one big problem at the moment: it's not @safe and can only be @safe with DIP1000. This is actually blocking a lot of work - think RCString, containers or even just a simple range which needs heap memory as state.

Reply via email to