Re: D Cookbook range save question

2020-01-30 Thread Adam D. Ruppe via Digitalmars-d-learn
(I'll answer here anyway just in case someone lands here via a web search.) On Thursday, 30 January 2020 at 10:31:08 UTC, mark wrote: Why is this a *copy*? (For a copy (in C++) I'd have expected return *this.) In C++, `this` is a pointer, but in D, it is a reference. So assignment follows th

D Cookbook range save question

2020-01-30 Thread mark via Digitalmars-d-learn
In the D Cookbook it has as part of the FibonacciRange example: @property FibonacciRange save() { return this; } And in the description it says: "...save, which returns a new range that is a copy of the current range and can be advanced independently..." Why is this a *copy*? (For a copy (in

Re: D Cookbook range save question

2020-01-30 Thread mark via Digitalmars-d-learn
On Thursday, 30 January 2020 at 10:31:08 UTC, mark wrote: In the D Cookbook it has as part of the FibonacciRange example: @property FibonacciRange save() { return this; } And in the description it says: "...save, which returns a new range that is a copy of the current range and can be advance