On Wednesday, 7 July 2021 at 01:44:20 UTC, Steven Schveighoffer
wrote:
This is pretty minimal, but does what I want it to do. Is it
ready for inclusion in Phobos? Not by a longshot! A truly
generic interleave would properly forward everything else that
the range supports (like `length`, `save`, etc).
But it got me thinking, how often do people roll their own vs.
trying to compose using existing Phobos nuggets? I found this
pretty satisfying, even if I didn't test it to death and maybe
I use it only in one place. Do you find it difficult to use
Phobos in a lot of situations to compose your specialized
ranges?
I try to compose using existing Phobos facilities, but don't
hesitate to write my own ranges. The reasons are usually along
the lines you describe.
For one, range creation is easy in D, consistent with the pro/con
tradeoffs described in the thread/talk [Iterator and Ranges:
Comparing C++ to D to
Rust](https://forum.dlang.org/thread/diexjstekiyzgxlic...@forum.dlang.org). Another is that if application/task specific logic is involved, it is often simpler/faster to just incorporate it into the range rather than figure out how to factor it out of the more general range. Especially if the range is not going to be used much.
--Jon