On Borrow Checking

Timon Gehr timon.gehr at gmx.ch
Sat May 3 21:44:06 UTC 2025


On 5/3/25 21:22, Walter Bright wrote:
> You add:
> 
> ```
> @live:
> ```
> 
> at the beginning of your modules.
> 
> Because it is opt-in with D rather than opt-out in Rust, does not alter 
> the fact that D has a borrow checker.
> 
> In Rust you can use "unsafe" to avoid the borrow checker.

These are disconnected and cherry-picked operational points without 
taking into account the semantics. Even if you added `@live @safe` on 
top of all your modules, you still would not get any aliasing guarantees.

```d
@live @safe:
class C{ int* x; }

void main(){
     auto x=new int;
     auto c=new C;
     c.x=x;
     auto y=c.x;
     assert(x is y);
     imported!"std.stdio".writeln(x,y);
}
```


More information about the Digitalmars-d mailing list