On Borrow Checking
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sat May 10 06:06:30 UTC 2025
On 10/05/2025 5:27 PM, Walter Bright wrote:
> 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
> ```
Yes, they were there for demonstration purposes to show what the state is.
More information about the Digitalmars-d
mailing list