Why can't I give a function's return type the scope storage class?

Walter Bright newshound2 at digitalmars.com
Tue Mar 19 02:03:12 UTC 2019


On 3/18/2019 10:20 AM, Meta wrote:
> So to be clear, you *can* add scope to the return type of a function, and it 
> will propagate the shortest lifetime among any parameters marked with `return` 
> or `return scope` to the return value?

No. Adding scope as the storage class of the function means it is attached to 
the 'this' parameter, if any.

Any 'return scope' parameter to the function will constrict the lifetime of the 
return value to that of the smallest lifetime of such arguments.


> Also, I'd like to echo the request that you document this stuff. What's already 
> there is fairly useful, but obviously it's not complete.

It can be improved. But my focus at the moment is getting Phobos to compile with 
-dip1000.


More information about the Digitalmars-d mailing list