Re: Bug with writeln?

2018-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 9, 2018 8:30:12 AM MDT Saurabh Das via Digitalmars-d- learn wrote: > Thank you for explaining all this. > > It is frustrating because the behaviour is very counterintuitive. > > I will use a workaround for now. Ranges are fantastic, and the basic concept is solid, but a

Re: Bug with writeln?

2018-09-09 Thread Saurabh Das via Digitalmars-d-learn
Thank you for explaining all this. It is frustrating because the behaviour is very counterintuitive. I will use a workaround for now. Saurabh

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
/18 12:55 PM, Jonathan M Davis wrote: > >>> It's not a bug in writeln. Any time that a range is copied, you must > >>> not > >>> do _anything_ else with the original unless copying it is equivalent > >>> to > >>> calling save on it,

Re: Bug with writeln?

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 2:52 PM, Jonathan M Davis wrote: On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: On 9/6/18 12:55 PM, Jonathan M Davis wrote: It's not a bug in writeln. Any time that a range is copied, you must not do _anything_ else

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/6/18 12:55 PM, Jonathan M Davis wrote: > > On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via > > Digitalmars-d-> > > learn wrote: > >> Is this a

Re: Bug with writeln?

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 12:55 PM, Jonathan M Davis wrote: On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via Digitalmars-d- learn wrote: Is this a bug with writeln? void main() { import std.stdio, std.range, std.algorithm; auto a1 = sort([1,3,5,4,2]); auto a2 = sort([9,8,9

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via Digitalmars-d- learn wrote: > Is this a bug with writeln? > > void main() > { > import std.stdio, std.range, std.algorithm; > > auto a1 = sort([1,3,5,4,2]); > auto a2 = sort([9,8,9]); >

Re: Bug with writeln?

2018-09-06 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 6 September 2018 at 09:06:21 UTC, Simen Kjærås wrote: On Thursday, 6 September 2018 at 08:40:08 UTC, Saurabh Das wrote: Is this a bug with writeln? Yup. What happens is writeln destructively iterates over b[i]. Since b[i] is a forward range, this shouldn't be done destructively

Re: Bug with writeln?

2018-09-06 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 6 September 2018 at 08:40:08 UTC, Saurabh Das wrote: Is this a bug with writeln? Yup. What happens is writeln destructively iterates over b[i]. Since b[i] is a forward range, this shouldn't be done destructively. Instead, a copy should be made using b[i].save, somewhere deep

Bug with writeln?

2018-09-06 Thread Saurabh Das via Digitalmars-d-learn
Is this a bug with writeln? void main() { import std.stdio, std.range, std.algorithm; auto a1 = sort([1,3,5,4,2]); auto a2 = sort([9,8,9]); auto a3 = sort([5,4,5,4]); pragma(msg, typeof(a1)); pragma(msg, typeof(a2)); pragma(msg, typeof(a3)); auto b = [a1, a2

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread arturg via Digitalmars-d-learn
On Friday, 16 February 2018 at 13:57:07 UTC, Steven Schveighoffer wrote: You have a pretty good minimal test, put that in bugzilla along with the forum thread link and all the info we know. Mark it as a dmd bug, regression, along with the version where it regressed (2.076.1), and I would tag

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/16/18 8:51 AM, arturg wrote: On Friday, 16 February 2018 at 13:28:59 UTC, Steven Schveighoffer wrote: Strictly speaking, this is not necessarily proof that it's in phobos, there could have been changes elsewhere that cause one of the conditions to fail. However, testing this out, I

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread arturg via Digitalmars-d-learn
On Friday, 16 February 2018 at 13:28:59 UTC, Steven Schveighoffer wrote: Strictly speaking, this is not necessarily proof that it's in phobos, there could have been changes elsewhere that cause one of the conditions to fail. However, testing this out, I found something very weird. If you

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/16/18 8:16 AM, bauss wrote: On Friday, 16 February 2018 at 13:08:09 UTC, bauss wrote: On Friday, 16 February 2018 at 12:15:07 UTC, arturg wrote: On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile:     void delegate(void*) dg;     void delegate(void*)[]

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 February 2018 at 13:08:09 UTC, bauss wrote: On Friday, 16 February 2018 at 12:15:07 UTC, arturg wrote: On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg];

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 February 2018 at 12:15:07 UTC, arturg wrote: On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg]; dgs.writeln; dgs.remove(1).writeln(); if you comment out

Re: is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread arturg via Digitalmars-d-learn
On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote: this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg]; dgs.writeln; dgs.remove(1).writeln(); if you comment out dgs.writeln; it works as expected, it works if you use other types

is this a bug with writeln / std.algorithm.remove?

2018-02-16 Thread arturg via Digitalmars-d-learn
this code fails to compile: void delegate(void*) dg; void delegate(void*)[] dgs = [dg, dg, dg]; dgs.writeln; dgs.remove(1).writeln(); if you comment out dgs.writeln; it works as expected, it works if you use other types then void*: void delegate(int*) dg; void