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

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Thu Oct 20 23:09:36 PDT 2016


On 10/20/2016 9:37 AM, Dicebot wrote:
> But this is perfectly fine:
>
> @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

If foo was a member function, the 'scope' would be allowed and would apply to 
the 'this' reference.



More information about the Dlang-internal mailing list