August 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8571

           Summary: Defined exception for unequal zip lengths with
                    StoppingPolicy.requireSameLength
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-08-21 04:41:41 PDT ---
This is part of Zip.empty() of Phobos:


@property bool empty()
{
    final switch (stoppingPolicy)
    {
...
    case StoppingPolicy.requireSameLength:
        foreach (i, Unused; R[1 .. $])
        {
            enforce(ranges[0].empty ==
                    ranges.field[i + 1].empty,
                    "Inequal-length ranges passed to Zip");
        }
        return ranges[0].empty;
    }


I suggest to replace that enforce() with a throw of a definite exception, named like ZipUnequals or something like that, that allows for a clean catch: catching the enforce() exception is easy, but you can't be sure you are catching that specific zip enforce instead of another one or a bug.

Knowing that a zip(StoppingPolicy.requireSameLength, ...) has thrown an exception for unequal lengths is sometimes useful. When you want to use the zip results and you want to make sure they are equal in length, you want to catch just that specific length problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------