DIP1000: 'return scope' ambiguity and why you can't make opIndex work

Walter Bright newshound2 at digitalmars.com
Mon Jul 5 10:44:54 UTC 2021


On 7/5/2021 3:01 AM, ag0aep6g wrote:
> On Monday, 5 July 2021 at 09:28:47 UTC, Walter Bright wrote:
>>   ref int test(ref scope return int* p)
>>   {
>>      return *p;
>>   }
> [...]
>> Examining Dennis' table, it has a [ref return type] and a [scope value], and 
>> so the `return` applies to the pointer type.
> 
> I think you're misreading something there.
> 
> For reference, the table:
> 
>> **Does the `return` attribute apply to the parameter's `ref` or the pointer 
>> value?**
>> |                                  | `scope`   | no `scope` |
>> |----------------------------------|-----------|------------|
>> | `ref` return type / `ref` param  | **`ref`** | **`ref`**  |
>> | value return type / `ref` param  | **value** | **`ref`**  |
>> | `ref` return type / value param  | **value** | **value**  |
>> | value return type / value param  | **value** | **value**  |
> 
> Your test function has a `ref` return type and a `ref` parameter, so we're 
> looking at the first row. That row says `return` applies to the `ref` part of 
> the parameter (with and without `scope`).


I think you might be right.


More information about the Digitalmars-d mailing list