[swift-evolution] [RFC] New collections model: collections advance indices
dabrahams at apple.com
Tue Mar 8 11:21:19 CST 2016
on Tue Mar 08 2016, Антон Жилин <swift-evolution at swift.org> wrote:
> In the RFC, I see that indices only requires `next`.
In the RFC, there's no Index protocol at all; Indices
are required to be Comparable.
> I like this scheme a lot, it's very altruistic, like in C++. Get,
> increment, end check - nothing more is required to work with
FWIW, building a correct C++ iterator is so boilerplate-heavy and
occasionally subtle that people use libraries such as
> I like extracting everything optional to Collection hierarchy, and don't
> like adding Equatable, Comparable or Hashable constraints on
You can barely write any interesting generic algorithms at all without
the moral equivalent of Equatable indices.
> If you need Hashable in a specific scope, declare it as a generic
> constraint. I didnt really read the whole RFC, so I could have
> misunderstood something.
I don't support making indices Hashable at this time; IMO that's part of
a much larger discussion that we need to have about regular types and
implicitly-generated conformances. Comparable is arguable either way,
but we are proposing to require it in part to be able to test the
semantics of a valid Range.
More information about the swift-evolution