Future of SafeRefCounted

Dukc ajieskola at gmail.com
Tue Feb 25 11:46:44 UTC 2025


On Tuesday, 25 February 2025 at 00:17:19 UTC, Jonathan M Davis 
wrote:
> As for RefCounted specifically, I haven't looked at its 
> implementation recently, so I don't know why it can't be @safe, 
> but off the top of my head, I don't see why it can't be 
> possible to create something like RefCounted that is @safe.

I had another look at it, and my conclusion is, it actually 
doesn't require DIP1000. DIP25 is enough! If you don't recall, 
and if I understand it correctly DIP25 is essentially DIP1000 
limited only to `ref` and `return ref`. `scope`/`return scope` 
rules for pointers/slices/classes/struct/unions aren't included. 
It's already the default in the current language.

Now, it's still possible to escape the payload with the same 
tricks you could escape a pointer to stack in default D. But this 
will also be fixed if we implement Simple Safe D. DIP1000 is not 
strictly needed for this use case. Although in Simple Safe D the 
user will likely have to make temporary copies of the payload, or 
parts of it, that would be unneeded in present D or with DIP1000 
- just like when dealing with objects on the stack.


More information about the Digitalmars-d mailing list