Re: std.algorithm.joiner unexpected behavior

2017-09-11 Thread Sergei Degtiarev via Digitalmars-d-learn
On Friday, 1 September 2017 at 00:09:16 UTC, H. S. Teoh wrote: Consider the case where .front returns a subrange. As you state above, copying this subrange does not have defined behaviour. One reason is the difference in semantics between reference types and value types: the assignment

Re: std.algorithm.joiner unexpected behavior

2017-09-02 Thread Sergei Degtiarev via Digitalmars-d-learn
Let me clarify, what I was going to create was a small utility, analogous to Perl <> operator, taking a list of file names and allowing forward iteration as it would be single stream of text lines. It would take no time to write the range from scratch, but what are all the phobos primitives

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 05:37:20PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, August 31, 2017 14:09:55 H. S. Teoh via Digitalmars-d-learn [...] > I know. We've had this argument before. I know. Let's not rehash that. :-) [...] > Even copying ranges in generic code

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 31, 2017 14:09:55 H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, Aug 31, 2017 at 01:34:39PM -0600, Jonathan M Davis via > Digitalmars-d-learn wrote: [...] > > > In general, byLine does not work with other range-based algorithms > > precisely because it reuses the buffer.

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 01:34:39PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: [...] > In general, byLine does not work with other range-based algorithms > precisely because it reuses the buffer. I think that it does manage to > work for some, but IMHO, it should have just supported

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 31, 2017 18:43:40 Jesse Phillips via Digitalmars-d-learn wrote: > On Thursday, 31 August 2017 at 18:26:33 UTC, Sergei Degtiarev > > wrote: > > Hi, > > I tried to create a simple range concatenating several files, > > > > something like this: > > File[] files; > >

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 06:26:33PM +, Sergei Degtiarev via Digitalmars-d-learn wrote: [...] > File[] files; > > foreach(ln; joiner(files.map!(a => a.byLine))) > writeln(ln); You probably want to use byLineCopy instead. The problem here is that .byLine

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 31 August 2017 at 18:26:33 UTC, Sergei Degtiarev wrote: Hi, I tried to create a simple range concatenating several files, something like this: File[] files; foreach(ln; joiner(files.map!(a => a.byLine))) writeln(ln); and I see every

std.algorithm.joiner unexpected behavior

2017-08-31 Thread Sergei Degtiarev via Digitalmars-d-learn
Hi, I tried to create a simple range concatenating several files, something like this: File[] files; foreach(ln; joiner(files.map!(a => a.byLine))) writeln(ln); and I see every first line of each file is missing. However, when I do same thing with