[phobos] phobos commit, revision 1871

David Simcha dsimcha at gmail.com
Sun Aug 15 14:31:28 PDT 2010


I've added Lockstep to std.range, which allows things like:

foreach(a, b; lockstep(range1, range2)) {
     // Loop body.
}

If anyone really doesn't like it, it can be removed, but I've **really** 
wanted this functionality for a **long** time.

I considered integrating it into Zip, but decided against this because:

1.  DMD doesn't currently work properly in terms of overloading 
opApply-based foreach against range-based foreach, even when there is no 
ambiguity.

2.  Even if this gets fixed, there will still be ugly ambiguous cases if 
iterating with Proxy and iterating as individual variables are put in 
the same struct once bug 3444 
(http://d.puremagic.com/issues/show_bug.cgi?id=3444) gets fixed.

Using Zip for iterating in lockstep over ranges via foreach is just 
syntactically ugly enough that I never do it in practice.  This is 
mostly because I can't name the element variables individually and have 
to access them as members of a Proxy.  Zip has its place for things like 
sorting in lockstep, and I plan to improve/debug it, too, but I really 
felt that for simple foreach-based lockstep iteration, a separate struct 
was necessary.

On 8/15/2010 5:26 PM, dsource.org wrote:
> phobos commit, revision 1871
>
>
> user: dsimcha
>
> msg:
> Added Lockstep, hasLvalueElements.
>
> http://www.dsource.org/projects/phobos/changeset/1871
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>    



More information about the phobos mailing list