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

Walter Bright newshound2 at digitalmars.com
Wed Jul 31 07:09:09 UTC 2019


On 7/21/2019 5:05 PM, Mike Franklin wrote:
> void main() @safe
> {
>      S s;
>      for(int i = 0; i < 100; i++)
>          doSomething(s.foo(), s.bar());
> }
> 
> I still don't see how the compiler can know statically whether or not `foo()` 
> and `bar()` will return a reference to the same data.

Because they're both returning a reference to `s`. The compiler already checks 
this with dip25 and dip1000. This DIP just extends this to more checking.

> It appears a full ownership/borrowing system would make what this DIP is 
> proposing obsolete, and is the only way to properly do what this DIP is proposing.

A full OB requires the @live sections. This DIP makes it partially available in 
@safe sections, enough so containers can control access to their components.



More information about the Digitalmars-d mailing list