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

Walter Bright newshound2 at digitalmars.com
Tue Jul 6 05:15:24 UTC 2021


On 7/5/2021 4:36 AM, claptrap wrote:
> How the heck are us mere mortals supposed to use this stuff if you struggle to 
> understand what it means?

I make mistakes all the time. That's why D has unit tests built in, and an 
acceptance test suite.

One reason I like writing software is once I get it right, it stays right every 
time.

Actually, I find Dennis' table a tad confusing. An alternate formulation is:

---------
Consider the ambiguity of a `return ref scope` parameter. Which is it:

1. `return ref` and `scope`
2. `ref` and `return scope`

? The ambiguity is resolved by looking at the function return. If it returns
by `ref`, then it's (1), otherwise (2). This is evident in the table above.
This rule is arbitrary, precluding things like creating a `return ref` and
`return scope` for the same parameter.
----------


More information about the Digitalmars-d mailing list