Forward ranges in Phobos v2

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Nov 2 21:56:31 UTC 2021


On Tue, Nov 02, 2021 at 04:17:06PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> On 2021-11-02 15:32, Adam D Ruppe wrote:
> > On Tuesday, 2 November 2021 at 18:09:55 UTC, H. S. Teoh wrote:
> > > Why is this necessary?  I thought we're getting rid of
> > > std.range.interfaces.
> > 
> > It is actually really, really, useful. If phobos didn't offer it,
> > someone would reinvent it anyway.
> > 
> > (In fact, there's a lot of cases where using them is more efficient
> > than generating more and more code...)
> 
> Yah, polymorphism has its place. The only problem is passing around
> reference ranges. They should have a thin struct wrapper that carries
> the proper copy semantics.

Yes, so we need a standard way of constructing such wrappers.  Possibly
an addition to stdv2.range.interfaces?  Or maybe just have the wrapper
constructors return the constructed polymorphic range
pre-(shrink)wrapped. :-)


T

-- 
People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth


More information about the Digitalmars-d mailing list