[swift-evolution] Proposal: Add generator functions to the language

Andrey Tarantsov andrey at tarantsov.com
Fri Dec 11 20:20:48 CST 2015


> Another possible syntax, inspired by "throws".
> 
> func foo() yield -> String

Well, again, yielding is an implementation detail. What's the advantage vs returning Generator<String>? I don't think that lying about the return type is useful for anyone.

> I'm not sure what happens if a function both yields and throws.

An excellent question. We'd need another generator type with "next() throws".

A.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/cfec423a/attachment-0001.html>


More information about the swift-evolution mailing list