Must ranges support `r1 = r2;`?
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Mar 24 21:57:53 UTC 2018
On Sat, Mar 24, 2018 at 10:44:35PM +0100, ag0aep6g via Digitalmars-d wrote:
> Long version: <https://issues.dlang.org/show_bug.cgi?id=18657>
> ("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 assignment as expected - even though std.range doesn't mention
> it? Or should range-handling code never do that - even though it comes
> naturally and is widespread currently?
Short answer: if r1=r2 is meant to save the current position in the
range, that's wrong; it should be r1=r2.save instead.
Long answer: I'm on my phone and don't want to type too much, so I'll
leave the explanations to someone else. :-P
T
--
A linguistics professor was lecturing to his class one day. "In English," he said, "A double negative forms a positive. In some languages, though, such as Russian, a double negative is still a negative. However, there is no language wherein a double positive can form a negative." A voice from the back of the room piped up, "Yeah, yeah."
More information about the Digitalmars-d
mailing list