www.digitalmars.com         C & C++   DMDScript  

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


           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 puremagic.com
        ReportedBy: monarchdodra gmail.com

--- Comment #0 from monarchdodra 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

  //Split using back/popBack:

["", "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

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: -------
Oct 22 2012