Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread Jonathan M Davis via Digitalmars-d
On Monday, April 16, 2018 19:01:02 Jack Stouffer via Digitalmars-d wrote: > On Monday, 16 April 2018 at 16:22:04 UTC, Jonathan M Davis wrote: > > Well, the reality of the matter is that if RefRange's opAssign > > doesn't work the way that it works, then RefRange is broken and > > fails at its purpo

Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread Jack Stouffer via Digitalmars-d
On Monday, 16 April 2018 at 16:22:04 UTC, Jonathan M Davis wrote: Well, the reality of the matter is that if RefRange's opAssign doesn't work the way that it works, then RefRange is broken and fails at its purpose (and this is the designer of it speaking). So, if RefRange couldn't do what it's

Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread Jack Stouffer via Digitalmars-d
On Monday, 16 April 2018 at 16:15:30 UTC, H. S. Teoh wrote: I could come up with some pretty pathological range types for stress-testing, if you want. (These are actual range types I've used in my own code, I didn't set out to break Phobos, but it turned out that Phobos makes many unstated ass

Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread Jonathan M Davis via Digitalmars-d
On Monday, April 16, 2018 15:58:34 Jack Stouffer via Digitalmars-d wrote: > On Saturday, 24 March 2018 at 21:44:35 UTC, ag0aep6g wrote: > > Long version: > > ("std.range and std.algorithm can't handle refRange"). > > > > Short version: With two `std.

Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread H. S. Teoh via Digitalmars-d
On Mon, Apr 16, 2018 at 03:58:34PM +, Jack Stouffer via Digitalmars-d wrote: [...] > In a perfect world, we'd have a pre-constructed test suite that people > could plug their range (with some data in it) into, where all the > tests make sure all Phobos assumptions hold true. [...] We could per

Re: Must ranges support `r1 = r2;`?

2018-04-16 Thread Jack Stouffer via Digitalmars-d
On Saturday, 24 March 2018 at 21:44:35 UTC, ag0aep6g wrote: Long version: ("std.range and std.algorithm can't handle refRange"). Short version: With two `std.range.RefRange`s, `r1 = r2;` does not what other Phobos code expects. Question is: Wh

Re: Must ranges support `r1 = r2;`?

2018-03-25 Thread ag0aep6g via Digitalmars-d
On 03/25/2018 01:49 AM, Jonathan M Davis wrote: assignment really isn't part of the range API. I don't think that any of the range traits even test that assignment works on any level. So, it could be argued that generic, range-based functions simply shouldn't ever be assigning one range to anothe

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread Jonathan M Davis via Digitalmars-d
On Sunday, March 25, 2018 00:28:32 ag0aep6g via Digitalmars-d wrote: > On 03/25/2018 12:02 AM, Jonathan M Davis wrote: > > auto range2 = range1; // now, range1 can't be used until it's assigned > > to > > range2.popFront(); > > > > range1 = range2; // now, range2 can't be used until it's assigned t

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread ag0aep6g via Digitalmars-d
On 03/25/2018 12:02 AM, Jonathan M Davis wrote: auto range2 = range1; // now, range1 can't be used until it's assigned to range2.popFront(); range1 = range2; // now, range2 can't be used until it's assigned to range1.popFront(); And I don't think that RefRange violates that. What RefRange vio

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread ag0aep6g via Digitalmars-d
On 03/24/2018 11:36 PM, Simen Kjærås wrote: void main() {     import std.range;     import std.stdio;     string s = "foo";     auto r = refRange(&s);     auto r2 = r;     r2 = r2.save;     /* Surprising: Effectively just does `s = s;` (i.e., nothing). */     r2.popFront();     wr

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread Jonathan M Davis via Digitalmars-d
On Saturday, March 24, 2018 22:44:35 ag0aep6g via Digitalmars-d wrote: > Long version: > ("std.range and std.algorithm can't handle refRange"). > > Short version: With two `std.range.RefRange`s, `r1 = r2;` does not what > other Phobos code expects. >

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread Simen Kjærås via Digitalmars-d
On Saturday, 24 March 2018 at 22:36:55 UTC, Simen Kjærås wrote: struct RefRange(R) { R* innerRange; this(R* innerRange) { this.innerRange = innerRange; } void popFront() { innerRange.popFront(); } @property auto front() { return innerRange.front;

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread Simen Kjærås via Digitalmars-d
On Saturday, 24 March 2018 at 21:44:35 UTC, ag0aep6g wrote: Long version: ("std.range and std.algorithm can't handle refRange"). Short version: With two `std.range.RefRange`s, `r1 = r2;` does not what other Phobos code expects. Question is: Wh

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread ag0aep6g via Digitalmars-d
On 03/24/2018 10:57 PM, H. S. Teoh wrote: On Sat, Mar 24, 2018 at 10:44:35PM +0100, ag0aep6g via Digitalmars-d wrote: [...] Short version: With two `std.range.RefRange`s, `r1 = r2;` does not what other Phobos code expects. [...] Short answer: if r1=r2 is meant to save the current position in

Re: Must ranges support `r1 = r2;`?

2018-03-24 Thread H. S. Teoh via Digitalmars-d
On Sat, Mar 24, 2018 at 10:44:35PM +0100, ag0aep6g via Digitalmars-d wrote: > Long version: > ("std.range and std.algorithm can't handle refRange"). > > Short version: With two `std.range.RefRange`s, `r1 = r2;` does not > what other Phobos code expe

Must ranges support `r1 = r2;`?

2018-03-24 Thread ag0aep6g via Digitalmars-d
Long version: ("std.range and std.algorithm can't handle refRange"). Short version: With two `std.range.RefRange`s, `r1 = r2;` does not what other Phobos code expects. Question is: Who's at fault? Where do I fix this? Do ranges have to support