DIP 1022---foreach auto ref---Community Review Round 2

Dukc ajieskola at gmail.com
Sun Oct 20 16:47:47 UTC 2019


On Sunday, 20 October 2019 at 08:32:57 UTC, Walter Bright wrote:
> I find the Rationale section to be completely confusing as to:
>
> 1. what the existing state of the compiler is
> 2. what the proposed change is

What do you suggest? Mike said that it's standard procedure to 
put rationale first and description of the change second. How can 
I be more explicit?

>
> For example,
>
> "A pull request[3] was submitted to disallow this behavior."
>
> That PR was merged, although the Rationale implies it was not.

The rationale says that it did not end up disabling `foreach` by 
`ref` over rvalue ranges - the PR was merged, but the final 
change was not what it was when Andrei commented. Byt yea, I 
should have been more explicit.

>
> Further, that PR appears to disallow ref being applied to 
> temporaries, yet the prose goes on to imply it does:
>
> "If a range with non-reference semantics is accidently passed 
> to such a loop, it will be iterated by value, which is likely 
> to be unexpected."

That phrase means the current situation, not the one after the 
DIP. Is there something that implies otherwise?

>
> The "A simple example" is not simple at all, because it imports 
> std.range:iota and is not possible to understand without 
> examining the source to iota.

Now when I think of it, I can as well make the `foreach`s iterate 
over `0 .. 5` instead. Didn't occur to me when I made that 
example.


More information about the Digitalmars-d mailing list