Is there any reason to use non-ref foreach?

Andrea Fontana nospam at example.com
Tue Sep 4 08:17:14 UTC 2018


On Tuesday, 4 September 2018 at 07:06:43 UTC, Dukc wrote:
> 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.

Waiting for this to be merged:
https://github.com/dlang/dmd/pull/8437



More information about the Digitalmars-d-learn mailing list