The Phobos Put

Steven Schveighoffer schveiguy at gmail.com
Wed Mar 29 20:50:04 UTC 2023


On 3/29/23 4:29 PM, ag0aep6g wrote:

> But regardless of Salih's exact intent, the broader point is: a non-ref 
> overload could be added to Phobos. And that would enable 
> `a[1..$-1].phobos_put([2, 3])`. Which is what he asked about originally.

I think the idea of requiring ref output ranges is that you can then let 
the range keep track of its output state.

An input range with lvalue elements is therefore an output range, but 
only if it's accepted via ref, since it has to be iterated as it goes. 
If you iterate it only internally, then it's either in an undetermined 
state when you exit `put`, or it is a forward range that was copied 
without using `save`.

It's not the greatest situation. I feel like we probably shouldn't have 
made lvalue input ranges be output ranges automatically.

-Steve


More information about the Digitalmars-d-learn mailing list