[swift-evolution] Should all GeneratorTypes also be SequenceTypes?

Dmitri Gribenko gribozavr at gmail.com
Mon Mar 14 19:50:24 CDT 2016


On Mon, Mar 14, 2016 at 4:42 PM, Haravikk via swift-evolution
<swift-evolution at swift.org> wrote:
> There are quite a lot of generator implementations that also implement SequenceType (since it’s as simple as returning self). Indeed, the AnyGenerator type conforms to SequenceType, allowing any generator to be wrapped as a sequence, though I imagine this comes with some overhead. So it got me thinking, why doesn’t GeneratorType just require conformance to SequenceType?

Because of compiler bugs.  We have the default implementation in the
library already, we just can't declare the conformance.

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