std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]
Jon Degenhardt
jond at noreply.com
Sat Jun 20 21:12:40 UTC 2020
On Saturday, 20 June 2020 at 20:17:29 UTC, Steven Schveighoffer
wrote:
> On 6/20/20 3:23 PM, Jon Degenhardt wrote:
>> On Saturday, 20 June 2020 at 18:26:43 UTC, Steven
>> Schveighoffer wrote:
>>> But the larger point is that true input-only ranges are rare.
>>> The only problem is for classes, since you cannot invoke a
>>> copy constructor on those.
>>
>> Interesting discussion. Could you expand on this comment?
>> Several people have mentioned this.
>
> There are a few "base" ranges, like arrays, and data structure
> ranges. The one common true "input-only" range is a
> stream-based range (like File.byLine).
Thanks for the detailed reply, it's very helpful and I'm finding
the discussion useful.
Another potentially useful example is a stream of random numbers,
where it may be undesirable to allow the state of the random
number stream to be copied.
> An input range is generally useful in foreach, and almost
> nothing else.
Here I might disagree a bit. Nearly all the algorithms in
std.algorithm.iteration (map, filter, fold, etc.) operate on
input-only ranges. These are important classes of operations.
They are largely alternate forms of foreach, so likely this is
more clarification than disagreement.
Related thought: One-time iteration of a stream is common in many
of the apps I write. I tend to think of such streams as logically
input-only. Whether it's valid/legal to copy the stream at
implementation level is a different question. More recently I've
finding reasons to enforce at most once iteration, even if the
underlying data structures (like an array) don't care.
--Jon
More information about the Digitalmars-d
mailing list