Forward ranges in Phobos v2
Paul Backus
snarwin at gmail.com
Thu Nov 4 16:39:24 UTC 2021
On Thursday, 4 November 2021 at 15:29:59 UTC, Andrei Alexandrescu
wrote:
> Usability is another matter that hasn't been quite looked at.
> Once you have a scoped pointer wrapper, what can and what can't
> you do with it easily? I'm not very sure.
>
> Alias this is just poorly done. I think we shouldn't base a
> fundamental API on it.
Both good points. It will take some experimentation to find out
where the rough edges of this approach are, and whether they can
be adequately sanded down.
> Anyway, I'm cautiously optimistic. At the very least this
> should be explored.
>
> Note that the whole thing still doesn't address unbuffered
> ranges. There must be a buffer of at least one element
> somewhere. That's... problematic.
Unbuffered ranges will return `Option!T` from `next`, rather than
`Option!(Ref!T)`.
Again, this is the same distinction we already have between
rvalue `front` and lvalue `front`, so I don't think the
inconsistency is a problem, as long as we can make `Ref!T`
function as a subtype of `T` (either via `alias this` or some
more principled mechanism).
More information about the Digitalmars-d
mailing list