On Borrow Checking
Walter Bright
newshound2 at digitalmars.com
Sat May 10 05:27:39 UTC 2025
On 5/9/2025 9:40 PM, Richard (Rikki) Andrew Cattermole wrote:
> ```d
> void func(scope ref int*) {}
>
> unique(int*) a = ...;
> assert(a !is null);
>
> unique(int*) b = a;
> assert(a is null);
> assert(b !is null);
>
> func(b); // ok
> ```
With a borrow checker like in @live, such asserts serve no purpose:
```
int* a = ...;
int* b = a; // ownership transferred to b
*a = 3; // error, ownership was transferred out of a
```
More information about the Digitalmars-d
mailing list