Friends don't let friends use inout with scope and -dip1000

Atila Neves atila.neves at gmail.com
Mon Aug 20 13:04:02 UTC 2018


On Monday, 20 August 2018 at 09:43:46 UTC, Nicholas Wilson wrote:
> On Monday, 20 August 2018 at 09:31:09 UTC, Atila Neves wrote:
>> On Friday, 17 August 2018 at 13:39:29 UTC, Steven 
>> Schveighoffer wrote:
>>>> [...]
>>>
>>> Does scope apply to the return value or the `this` reference?
>>
>> I assumed the return value. I think I've read DIP1000 about a 
>> dozen times now and I still get confused. As opposed to 
>> `const` or `immutable`, `scope(T)` isn't a thing so... I don't 
>> know?
>>
> What usually happens is that qualifiers to the left of the name 
> apply to the return type and those to the right apply `this`. 
> Not that that _should_ make any difference since lifetime ints 
> == lifetime this
>
>>> What happens if you remove the return type? (i.e. scope auto)
>>
>> And write what instead?
>>
>
> scope ptr() inout { return ints; } ?

I guess you meant `scope ptr(this This)() { return this; }`. 
Nothing changes from the behaviour I described.


More information about the Digitalmars-d mailing list