Just another idea.

So as I understand https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#owning-containers there is problem with safe assignment of slices. But the problem is actual only if some element has scope ref.

1. Lets introduce type state "referred".
```
//safe code
RCSlice!int a = ...; // a is not refferd
RCSlice!int c = ...;
{
scope ref e = a[0]; // a is reffered
...; // a is reffered
auto b = a; // b is a copy and not refferd
b=c; // in fact it is safe. assignment to b will not destroy "e"
}
...; // a is not refferd
```
2. function attribute @disable_if(arg)
this attribute will disable function (in the same way as @disable does)
depending on its arg.
opAssign(RefCountedSlice rhs) @disable_if(reffered) @trusted
This way assign can by trusted
For simplicity only allow @disable_if to depend on "this" state.
3.Forbid to create refs/ptr to var with typestate (only to pass as "this"). It would simplify typestate tracking. But it could be hard to define what is var with typestate.

So how do you think about all this?

Reply via email to