Difference between range `save` and copy constructor

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sun Feb 16 20:20:12 UTC 2020


On Sunday, February 16, 2020 12:22:01 PM MST Paul Backus via Digitalmars-d-
learn wrote:
> On Sunday, 16 February 2020 at 18:11:11 UTC, Jonathan M Davis
>
> wrote:
> > Either way, generic code should never be using a range after
> > it's been copied, and copying is a key part of how idiomatic,
> > range-based code works in D.
>
> "Copy and then never use the original again" is conceptually the
> same thing as "move", right? In which case, generic code can
> accommodate non-copyable ranges *and* more clearly communicate
> its intent by using `move` instead of a naked copy.

We already have enough of a mess with save without making things even worse
by trying to add moves into the mix. Also, non-copyable ranges have never
really been a thing, and I really don't want to see things complicated even
further trying to support such an uncommon use case. There are too many
weird corner cases with ranges as it is.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list