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

Dmitri Gribenko gribozavr at gmail.com
Tue Mar 8 13:42:18 CST 2016


On Sun, Mar 6, 2016 at 5:58 PM, Kevin Ballard via swift-evolution
<swift-evolution at swift.org> wrote:
> That's a fair point. But I think the important sentence from my comparison to Rust is "And in practice, almost nobody ever has to actually use .fuse(), …".

The concern is that people who do need to invoke .fuse(), won't,
because all generators they are likely to try in practice will 'just
work' and return a continuous stream of nils.

I think what this really comes down to is the trade off between a
subtle correctness issue and a small performance win for a small
number of data types (which can be even non-existent as Patrick
Pijnappel shows).  Given the general direction of Swift, I'm inclined
to choose correctness here.

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