3 ms·
I still don't understand how that works. How do you avoid having two unique, mutable references to the same value in that case? For example (pseudocode):
by pcwalton 7y ago
I still don't understand how that works. How do you avoid having two unique, mutable references to the same value in that case?
For example (pseudocode):
void f(shared_ptr<Foo> a, shared_ptr<Foo> b) {
g(&mut *a.field, &mut *b.field);
}
This is unsafe because a and b might point to the same object.
- complistic 7y agoThat is what the part of this idea that Walter is tackling first, See https://github.com/dlang/DIPs/blob/master/DIPs/DIP1021.md https://github.com/dlang/DIPs/blob/master/DIPs/DIP1021.md The short of it is that the compiler will enforce that the same pointer is not provided to function more then once at the call site.