[swift-evolution] [Proposal] Change guarantee for GeneratorType.next() to always return nil past end

Dmitri Gribenko gribozavr at gmail.com
Tue Mar 8 19:03:28 CST 2016


On Tue, Mar 8, 2016 at 4:50 PM, Kevin Ballard <kevin at sb.org> wrote:
> In fact, it's the only requirement not enforced by the type system that a GeneratorType implementation must conform to.

That's not true.  Once you start putting generators into a larger
context, you have:

- collection's generator should generate the same elements as
subscripting would produce;

- a generator for a sequence should produce at least
`underestimatedCount` elements;

- a generator for a sequence should produce the same elements as the
`forEach` method;

- lots and lots of similar high-level relationships.

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