Issue 1974 - What's your opinion?
Timon Gehr
timon.gehr at gmx.ch
Fri Oct 25 11:44:46 UTC 2019
On 24.10.19 13:45, Dukc wrote:
> On Thursday, 24 October 2019 at 08:02:28 UTC, RazvanN wrote:
>> Hello everyone,
>>
>> [snip]
>
> The root cause here, I think, is that `Foo.opAddAssign` takes the
> implicit member parameter as `auto ref`
That's not what `auto ref` means! The `this` parameter is a `ref`
parameter within the body of the called member function, so it is not
`auto ref`.
> when in this case it would be
> more appropriate to take it as `ref`.
> ...
It does take the parameter by `ref`.
> Unfortunately, you can't mark it like that - `void opAddAssign(int z)
> ref { _this.y += z; }` fails to compile. Perhaps it should?
>
>
`ref` on a function applies to the return value.
More information about the Digitalmars-d
mailing list