Difference between input range and forward range
via Digitalmars-d
digitalmars-d at puremagic.com
Tue Nov 10 08:33:01 PST 2015
I agree with these considerations. When I define non-copyable
range (with disabled this) lot of standard phobos functions fails
to compile instead of using *save* method. So logical question is
in which cases we should use plain old struct copy or and when we
should use *save* on forward ranges.
Also good question is should we have input ranges copyable (or
for what types of ranges they can be copyable)? Good example is
network socket as input range, because we can't save the state of
socket stream and get consumed data again so as I thing copying
of such range looks meaningless (in my opinion). If we want to
pass it somewhere it's better pass it by reference.
Also passing range somewhere to access it in two different places
simultaneously is also bad idea. The current state looks like we
have current approach with range postblit constructor and +save+,
because we have it for structs and it works somehow (yet) for
trivial cases. But we don't have clear intentions about how it
should really work.
Copying and passing ranges should also be specifyed as part of
range protocol, because it's very common use case and shouldn't
be ambigous.
Also as far as range could be class object we must consider how
should they behave?
Is there some ideas and understanding of what I am talking about?
More information about the Digitalmars-d
mailing list