Phobos for Review: std.buffer.scopebuffer

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 7 21:11:57 PST 2014


On Friday, February 07, 2014 22:15:11 Jakob Ovrum wrote:
> On Friday, 7 February 2014 at 21:24:16 UTC, Brad Anderson wrote:
> > On Friday, 7 February 2014 at 21:05:43 UTC, Jerry wrote:
> >> I'd suggest reversing the arguments:
> >>  void buildPath(IR, OR)(OR result, IR segments)
> >>  
> >>      if (isInputRange!IR && isOutputRange!(OR, char));
> >> 
> >> That way you can use it as:
> >> 
> >> buffer.buildPath(p1, p2, ...);
> >> 
> >> It at least opens up chaining possibilities.
> > 
> > On the other hand the output buffer last allows stuff like this
> > contrived example:
> > 
> > "some/foo/path"
> > 
> >   .splitter("/")
> >   .buildPath(buffer);
> > 
> > I'm not sure what would be more common and useful.
> 
> Those are two different overloads, so I think we could do both.

That's assuming that the same type wouldn't match both parameters, which would 
be very easy to do if you end up with any ranges that function as both input 
and output ranges (e.g. dchar[] would match both). I'm not sure how often 
you'd get an ambiguity error in practice, but it seems risky to me - and it 
potentially makes it harder to read code that uses it if you can arbitrarily 
flip the arguments.

- Jonathan M Davis


More information about the Digitalmars-d mailing list