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

ag0aep6g anonymous at example.com
Mon Jul 5 10:01:28 UTC 2021


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`).




More information about the Digitalmars-d mailing list