> Dangling pointers are turned into spurious reads of data and the data is kept 
> alive for longer than the programmer anticipated. That should raise some 
> suspicion, at least.

Well, that's the Schrödinger's cat dilemma: No one knows if the cat in the box 
is dead or alive, as long as no one observes it. But if and when someone 
observes it, he wants the cat alive. The GC ensures that the cat will stay 
alive as long as at least one _potential_ observer exists. It is not 
necessarily a logical error then.

A "real" `owned ptr` would neither accept other references pointing to the data 
structure, nor pointers/references in the data structure pointing to already 
shared references. In this specific case, the `owned ptr` can be regarded 
_isolated_ and transferred safely to other threads. This should be ensured by 
the compiler.

So, if you want the full power of semi-automatic MM (multi-threading intended) 
the type system may get extended a bit. The `owned ptr` is one of these 
extensions, `lent` another one, and it seems that a single `lent` type is not 
enough. The basic principle of `lent` : As long as a `lent` is active, the 
`owned ptr` has to stay in suspended mode . When the `lent` leaves the scope, 
the `owned ptr` becomes empowered again. No dynamic checks against null, no RC 
needed. Anything happens statically. Sounds easy, but it isn't. 

Reply via email to