Range Redesign: Copy Semantics

H. S. Teoh hsteoh at qfbox.info
Tue Jan 23 16:34:07 UTC 2024


On Tue, Jan 23, 2024 at 09:19:24AM +0000, Atila Neves via Digitalmars-d wrote:
> On Monday, 22 January 2024 at 17:07:05 UTC, H. S. Teoh wrote:
> > On Mon, Jan 22, 2024 at 03:41:35PM +0000, Atila Neves via Digitalmars-d
> > wrote:
> > > On Sunday, 21 January 2024 at 05:00:31 UTC, Jonathan M Davis wrote:
> > > > [...]
> > > 
> > > I don't think I've ever encountered a situation where reference
> > > ranges would have been desirable - I've never used one.
> > 
> > It's useful in recursive-descent parsers where you expect the range
> > to have advanced past whatever a recursive call has consumed.
> 
> Why can't this be done with value ranges?
[...]

Because the recursive call advances a value copy of the passed range,
and when it returns, the range in the caller is still in the old
position.


T

-- 
"Hi." "'Lo."


More information about the Digitalmars-d mailing list