Is there any reason to use non-ref foreach?

Dukc ajieskola at gmail.com
Tue Sep 4 07:06:43 UTC 2018


On Monday, 3 September 2018 at 13:34:36 UTC, Andrea Fontana wrote:
> On Friday, 31 August 2018 at 09:59:20 UTC, Dukc wrote:
>> For me, it seems that for generality you should always add ref 
>> into foreach loop variable. The reason is this:
>
> One good reason:
> https://forum.dlang.org/thread/dlhrrgvzmhladnphidei@forum.dlang.org

I am almost sure it will stay how it is, because of the sheer 
amount of breakage changing that would cause. I still agree that 
in princliple, the general way to iterate should be something 
else (auto ref?). But as with autodecoding, the present way is 
already in too wide use to be worth changing.

But I think we need an official line to confirm whether one can 
use that without risking a deprectation.


More information about the Digitalmars-d-learn mailing list