DIP69 - Implement scope for escape proof references

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 4 16:23:16 PST 2014


On 12/4/2014 1:54 PM, Martin Nowak wrote:
> On 12/04/2014 09:41 PM, Walter Bright wrote:
>>
>> Yes, it would be written:
>>
>>    scope ref T setVal(ref T t)
>>    {
>>       t.val = 12;
>>       return t;
>>    }
>
> But when there is no scope on the argument, I could not call setVal with a local
> T variable.

Actually, you can. The difference between 'ref' and 'scope ref' parameters is 
the latter cannot be returned by ref.


More information about the Digitalmars-d mailing list