Safe Memory Management and Ownership.

xray xray at isd.lu
Thu Jul 12 21:31:04 UTC 2018


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:
>> The message above is repost of :
>>
>> https://forum.dlang.org/post/pfjotkcazuiuhlvzijih@forum.dlang.org
>>
>> So I can reply to Chris M. here.
>>
>> ------------------------------------------------------------------
>>
>> Yes, Chris, I got inspired by Rust :)  But Rust goes too far 
>> and it lowers the productivity. Nevertheless, it demonstrates 
>> that we can make the compiler do a great deal of things 
>> regarding MM.
>> I have also got inspired by how we could make "a better C" and 
>> the main issue in C is that it's easy to get lost in MM 
>> responsibility.
>>
>> Regarding D, the problem is that if you use the GC, you are in 
>> competition with Go. So it would be vital for D to get rid of 
>> the GC (or at least, make it optional, even with Phobos).
>>
>> I will go deeper and look at dip25 and dip1000.
>
> 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.




More information about the Digitalmars-d mailing list