[Dlang-internal] DIP1000 discussion and testing: borrowing a range

Martin Nowak via Dlang-internal dlang-internal at puremagic.com
Fri Oct 21 10:38:46 PDT 2016


On Friday, 21 October 2016 at 06:09:36 UTC, Walter Bright wrote:
>> @safe scope int* foo (return scope ref int r) {
>>     return &r; // taking address of r is fine because returned 
>> pointer
>> can't outlive the reference
>> }
>
> Nope:
>
>   Error: function foo functions cannot be scope

Scope was supposed to apply to the return value, comare 
https://github.com/dlang/DIPs/blob/731255ed7dc37d596fec0552013f0e12c68f7bea/DIPs/DIP1000.md#scope-function-returns.

Let's maybe work with a better equivalent example.

@safe scope Klass get(return scope ref Unique!Klass);


More information about the Dlang-internal mailing list