[swift-evolution] [RFC] New collections model: collections advance indices
Dmitri Gribenko
gribozavr at gmail.com
Tue Mar 1 21:01:25 CST 2016
On Tue, Mar 1, 2016 at 6:55 PM, Trent Nadeau <tanadeau at gmail.com> wrote:
> Why is the protocol for iterators called IteratorProtocol instead of
> Iterator or Iterable? If that is/was discussed elsewhere, I apologize, but I
> don't remember seeing that particular name before. Is that new to this
> proposal?
I'm using the new names introduced by SE-0006
https://github.com/apple/swift-evolution/blob/master/proposals/0006-apply-api-guidelines-to-the-standard-library.md
The protocol is not called Iterator to disambiguate it with the
Iterator associated type in Sequence from the protocol:
protocol Sequence {
associatedtype Iterator : IteratorProtocol
}
It is not called Iterable because that would have the wrong meaning
(Sequence is iterable, the iterator iterates over its elements).
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the swift-evolution
mailing list