Allocator-aware @safe reference counting is still not possible

Paul Backus snarwin at gmail.com
Tue Jan 24 16:11:00 UTC 2023


On Tuesday, 24 January 2023 at 15:03:46 UTC, Dukc wrote:
> On Tuesday, 24 January 2023 at 14:51:06 UTC, Dukc wrote:
>> I agree with you that we do not want to wait for any major 
>> language-level changes, considering how long it took for 
>> DIP1000 to become stable.
>
> Also I suspect the benefit-to-complexity ration of `isolated` 
> or a complete borrow checker would be poor. It fits Rust, since 
> it's a dedicated systems programming language. D is an 
> application programming and scripting language as much as it's 
> a systems language, so for us it isn't as good fit.

It's worth noting that D already has a bunch of special-case 
language rules that would be unified by adding `isolated`.

For example: return values of so-called ["Pure factory 
functions"][1] are allowed to implicitly convert to `immutable`, 
because "all mutable memory returned by the call cannot be 
referenced by any other part of the program"--or, in other words, 
the return value is `isolated`.

There's a similar rule for `new` expressions, although it doesn't 
seem to be written down anywhere. You can see it at work in code 
like this:

```d
// converts from mutable to immutable
immutable(int[][]) a = new int[][](3, 3);
```

Replacing all of these special cases with a single consistent set 
of rules would help simplify the language.

[1]: https://dlang.org/spec/function.html#pure-factory-functions


More information about the Digitalmars-d mailing list