On Monday, April 17, 2017 19:39:25 Stanislav Blinov via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 19:00:44 UTC, Jonathan M Davis wrote: > > Because otherwise, it's not acting like a reference to the > > original range, which is the whole point of RefRange. The > > correct solution would probably be to @disable opAssign in the > > case where the original range can't be overwritten by another > > range. > > This doesn't look quite right. References in D are rebindable. > That is, assigning a reference to a reference does not copy > referenced object, only the reference itself. > It seems that RefRange is trying to impersonate a C++ reference.
The term reference in D is a bit overloaded. The whole point of RefRange is to have the original range affected by everything that happens to the new range as if it were the original range - which is what happens with ref (which is not rebindable) except that ref only works on parameters and return types. So, yes, it is similar to a C++ reference. It's not trying to be a pointer, which is more like what a class reference is. - Jonathan M Davis