On Thursday, 12 July 2018 at 21:31:04 UTC, xray wrote:
On Thursday, 12 July 2018 at 14:13:25 UTC, Chris M. wrote:
On Wednesday, 11 July 2018 at 22:59:50 UTC, xray wrote:
[...]

I feel the following should be disallowed, since we've moved some checking to runtime. Ideally this system would all happen at compile-time.

auto r3 = r2; // Smooth reference
auto w = r3.getWidth(); // An exception is raised if r3 is not valid.

If we disallow the use of smooth references, we fall into the same paradigm as Rust. Then it's going to be hard to implement data structures with many references to the same object and the language becomes less flexible.

But yes, I assume we are in Safe Memory Management so that we can do :

if ( isValidRef(r3) ) {
   auto w = r3.getWidth();
}

Also, I have started to look at the dip-1000. At first glance, "scope" is an approach that makes sense but it does not seem to fit with the "ownership" concept that I suggest, ...unless someone has a brilliant idea to reconcile all those concepts.

I was concerned there may have been a conflict between your idea and DIP1000, but now that I look closer that may not be true. Maybe it could even help with smooth references?

auto r1 := new Ref();
scope r2 = r1; // we know r2 will not outlive r1

Reply via email to