Range Redesign: Copy Semantics
Nick Treleaven
nick at geany.org
Sun Jan 21 18:13:02 UTC 2024
On Sunday, 21 January 2024 at 13:48:56 UTC, Jonathan M Davis
wrote:
> And how on earth would you use a range if it can't be copied?
> They're copied all over the place and have to be to even be
> used. You copy them when you pass them to any range-based
> function. You copy them when you return them from a range-based
> function. You copy them when they get wrapped by another range.
> You copy them when you pass them to foreach. Disabling copying
> on ranges would make them borderline useless.
Maybe they could be moved instead of copied when the original is
not needed.
> And you also can't disable copying on classes or dynamic arrays.
Unless all ranges have to be structs, but then we probably need a
function/syntax to ask for a range from a class or dynamic array.
More information about the Digitalmars-d
mailing list