[Issue 8866] New: Splitter(R1, R2) CANNOT be bidirectional.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 22 03:08:07 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8866

           Summary: Splitter(R1, R2) CANNOT be bidirectional.
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2012-10-22 03:08:00 PDT ---
Because long story short: If a splitter "element" overlaps with another, the
the orientation of the splitting will influence the splitting. For example:
Given the string "aaab", and the splitter "ab":

//----
import std.string;
import std.algorithm;
import std.range;
import std.stdio;

void main()
{
  auto r = "aaab";
  auto sep = "aa";
  auto s = r.splitter(sep);

  //Normal split
  s.writeln();

  //Split using back/popBack:
  s.retro().array().retro().writeln();
}
//----

Produces:
["", "ab"]
["a", "b"]

This creates two different results.

I don't have a source for this, but I'm 99% sure that iterating a range
backwards should produce the same output as the reverse of the range iterated
forward.

Suggest removing backwards iteration on splitter(R1, R2), and add suggestion to
use splitter(R1.retro, R2.retro)

----
Note; splitter(R, Value) and splitter(terminator)(R) should be able to safely
iterate backwards.

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


More information about the Digitalmars-d-bugs mailing list