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

Manu turkeyman at gmail.com
Fri Aug 9 21:55:45 UTC 2019


On Fri, Aug 9, 2019 at 2:00 PM Dukc via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Friday, 9 August 2019 at 18:17:50 UTC, Manu wrote:
> > [snip]
>
> Wow! It seems that were on totally different pages here! I
> definitely have to check your link and think long and deeply
> about your comment before I know how to even begin my response.
> I'll likely make it tomorrow.
>
> Looks like an opening for an interesting debate, thanks for
> popping up!

Sorry if that sounded blunt.

Let me try and be more clear; by comparison, we can consider C++,
which has value, ref, and 'auto ref' foreach loops.
All 3 are valid operations, and we have the first 2, but not the 3rd.

C++: for (auto i : things)
D: foreach (i; things)

C++: for (const auto& i : things)
D: foreach (ref i; things) // <- this didn't used to work, but ref
FINALLY accepts rvalues by creating a temporary. I suspect you may be
confusing this case with your auto-ref proposal.

C++: for (auto&& i : things)
D: foreach (auto ref i; things)  // <- you are proposing this, and I
agree, we want this. I've wanted it many times.

I suspect from reading that you are trying to solve the second case
with this DIP, but it's already solved by Andrei's work (which he
presented at dconf).
What this DIP should actually solve though, in the 3rd case. We need that.


More information about the Digitalmars-d mailing list