Parameter storage classes on foreach variables

Nick Treleaven nick at geany.org
Mon May 20 14:29:48 UTC 2024


On Saturday, 18 May 2024 at 22:43:48 UTC, Timon Gehr wrote:
>> If mutating in place is desired, `ref` is an excellent choice.
>> However, if mere copy avoiding is desired, another great 
>> option would be `in`.
>
> I contest that `in` is a great option every time mere avoiding 
> of copies is desired (because it implies transitive `const`).

Did you mean "isn't a great option"?
And if so, presumably we still need `auto ref`:
https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1022.md

> In general, extending `foreach` to `in` and `out` makes some 
> sense, but `out` is likely to be quite controversial, 
> especially the output range lowering. When I think of 
> `foreach`, I think of consuming a range, not producing one.

+1


More information about the dip.ideas mailing list