Is borrow checker the right thing for D?

victoroak anyone at any.com
Sat Aug 17 12:36:12 UTC 2019


On Saturday, 17 August 2019 at 12:09:19 UTC, Timon Gehr wrote:
> 
> [...]
>
> None of the borrow/ownership proposals in the pipeline do 
> anything that would allow @trusted code to restrict the set of 
> possible access patterns from @safe code. They are a form of 
> Rust cargo cult.

As someone who likes Rust, I like the idea of having just one 
mutable reference to a strict. I'm no language designer but it 
makes sense to try to borrow a model that already works in 
another language. I do think that Rust has a lot more than just 
one mutable reference that contributes to the safety and maybe it 
does not makes sense for D to do that.

The problem is that I can't think any way besides returning a 
refcounted pointer in opIndex to make a safe Vector that has a 
reserve method or a insert that reallocate.

If you have a better way that does not involve copying Rust I 
think you could let us know.


More information about the Digitalmars-d mailing list