On Monday, 31 August 2020 at 05:46:45 UTC, ag0aep6g wrote:
`ref` kind of implies `scope` [1]. You don't need to type it
out. When you do type out `scope ref const(Price)`, the `scope`
actually doesn't apply to the `ref` but to the pointers in
`Price` (whereas the `scope` in `scope const(Price)[]` applies
to the pointer of the array).
So you don't need `scope` on the `price` parameter because
you're taking it as a `ref`. You would need `scope` if you were
taking it as a pointer (`scope const(Price)* price`).
By the way, semantically there isn't any reason to take `price`
as either `ref` or pointer. You can just as well take it by
value, since you're making a copy of it anyway with `minPrice =
price` (and you also make a copy earlier with `foreach (price;
prices)`).
Thank you for your advice.
I understand that I had abused `scope` parameter.
I don't think this is in Bugzilla yet. Please file an issue. Or
let me know if you want me to do it.
I have filed issue about `ref` parameter address check.
https://issues.dlang.org/show_bug.cgi?id=21212