On Monday, 12 November 2012 at 08:37:20 UTC, Tommi wrote:
This whole mess makes me wish that D was designed so that all types had value semantics (by convention, since it's probably not possible to enforce by the language).

That would mean:
1) No classes. Just duck-typing based polymorphism à la go language. 2) Dynamic arrays of mutable types would have had to been implemented as copy-on-write types à la Qt containers.

...forgot to add how this relates to this issue:

Then you'd solve this issue by specifying range concept so that front should return by value if it's transient, and front should return by reference or const reference if it's persistent. Then you'd capture front by const reference à la C++. If front returns reference or const reference, then const reference simply references that persistent data. If front returns by value (that's an rvalue from caller's point of view), then this C++ style const reference that we use for capture would extend the lifetime of this temporary rvalue to the const reference variable's scope. And, just to have some code in a post:

ref const auto saved = range.front;


Reply via email to