DIP 1021--Argument Ownership and Function Calls--Community Review Round 1

Nick Treleaven nick at geany.org
Thu Jul 18 11:18:29 UTC 2019


On Thursday, 18 July 2019 at 08:33:22 UTC, Olivier FAURE wrote:
> On Wednesday, 17 July 2019 at 23:26:20 UTC, Walter Bright wrote:
>> This is the principle pointed out in the "Prior Work" section. 
>> The DIP is not intended to be a tutorial on this, which is why 
>> there's a link to more explanation.
>
> By "more explanation", do you mean the Rust tutorial? Because 
> (1) pointing at an entire flippin' language and saying "There, 
> that's prior work, just read it if you have any questions"

The prior work section does not point to top-level rust-lang.org 
as you seem to suggest, but to this specific link:
https://doc.rust-lang.org/1.8.0/book/references-and-borrowing.html#the-rules

> The DIP says "The checks would only be enforced for @safe 
> code.", but your examples only show @system code.

You're right. I've made an example here:
https://forum.dlang.org/post/gdptdtqcethrldpsicss@forum.dlang.org

I see my example is wrong, the destructor can't be @trusted, but 
the DIP can at least detect a memory-safety problem.

>     foo(identity(&s), s.get()); // Does this compile in @safe ?

Since DIP 25, the compiler knows the result of identity has the 
same scope as its argument (in @safe code), so I expect the above 
would not compile with this DIP.



More information about the Digitalmars-d mailing list