Allocator-aware @safe reference counting is still not possible
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Jan 23 08:49:50 UTC 2023
On 23/01/2023 9:31 PM, Atila Neves wrote:
> On Sunday, 22 January 2023 at 15:50:27 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> On 23/01/2023 4:28 AM, Atila Neves wrote:
>>> [...]
>>
>> 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.
>>
>> [...]
>
> I don't understand your post. I've never seen anything resembling the
> "uncontrolled" above. I think the way to use allocators is via smart
> pointers/containers and iff it's strictly required.
I have written uncontrolled allocator usage. Its also in druntime/phobos
plenty. After all its basically just a life cycle is known but compiler
can't prove anything useful related to it. See any usage of malloc/free
(including internally to the GC).
But yes, I think the way to go is some sort of controlled representation
for normal usage (which requires borrowing, which @live does not solve).
```d
Vector!int vector;
vector ~= 3;
auto borrowed = vector[0];
func(borrowed);
void func(scope ref int value) {
}
```
Basically right now we're missing the lifetime checks surrounding
borrowed & function parameter. Everything else is do-able right now,
even if it isn't as cheap as it could be (like RC eliding).
More information about the Digitalmars-d
mailing list