Allocator-aware @safe reference counting is still not possible

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sun Jan 22 15:50:27 UTC 2023


On 23/01/2023 4:28 AM, Atila Neves wrote:
> I'm pretty much convinced we need isolated.

I'm not. When I first got a link to that paper I certainly didn't 
understand even the basic concepts. Variable based borrow checker is 
much easier to understand comparatively.

My general feeling is allocators get used in two scenarios:

- Controlled: this is your self contained data structure type scenario 
with RC. Safe, because if it wasn't the data structure wouldn't work.
- Uncontrolled: No lifetimes, either global heavy or only used with 
function body, which means fat slices and pointers (no thanks). Unsafe 
and cannot be made it (due to things like globals).

So there is no point in trying to make memory lifetimes of uncontrolled 
safe, because you shouldn't be doing this! Use a data structure instead.

That just leaves controlled, where @localsafe would be desirable (so you 
could call @system RCAllocator api). And having a better lifetime 
management strategy to and with RC (i.e. eliding & order of destruction 
via borrow checker).

Throw in value type exceptions as well, and ROM aware RC hooks; we'd be 
in a good place I think for this.


More information about the Digitalmars-d mailing list