std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]
Paul Backus
snarwin at gmail.com
Sun Jun 28 14:12:39 UTC 2020
On Saturday, 27 June 2020 at 20:14:36 UTC, Stanislav Blinov wrote:
>
> If the explanation is "`tail() const` is impure, and calling it
> repeatedly with the same `this` produces different results,
> even when `this` is immutable", "WTF???" would be quite a
> reasonable follow-up question. This is not malloc. If we do
> define a `tail` primitive, it better yield the same output for
> the same input, meaning it would only be a primitive of forward
> ranges.
It sounds like what you are really trying to say here is that
input ranges and forward ranges should not use the same
interface, and that input ranges should instead implement only
`Option!T next()`. I agree that this would be ideal, and that if
this change were made, tail() would be required only for forward
ranges and up. In that case, requiring tail() to be pure would
make sense.
My example was a response to the specific claim that "an
immutable input range cannot exist." Specifically, it was a
counterexample demonstrating that the claim is false. As I'm sure
you can see, the claim is still false even if we agree to use
next() instead of tail() for input ranges, since next() is
obviously allowed to be impure.
More information about the Digitalmars-d
mailing list