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

Jordan Rose jordan_rose at apple.com
Fri Dec 11 20:18:09 CST 2015


Another possible syntax, inspired by "throws".

func foo() yield -> String

I'm not sure what happens if a function both yields and throws. I guess that can't happen right now because generators are required not to throw when producing their next() value.

Jordan

> On Dec 11, 2015, at 18:14 , Jordan Rose <jordan_rose at apple.com> wrote:
> 
> It's desireable for the signature of a function to be fully checkable without looking at the body, for a number of reasons. It's also something clients of a library will want to know, so it needs to be displayed in the library's interface somehow.
> 
> Jordan
> 
> 
>> On Dec 11, 2015, at 18:03 , Andrey Tarantsov via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Do we actually need the "generator" keyword? Why can't the compiler figure it out by the presence of yield?
>> 
>> And "yield" is a fairly standard keyword across languages, so no harm in claiming it, IMO.
>> 
>> +1 on the proposal.
>> 
>> A.
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151211/9ae72931/attachment.html>


More information about the swift-evolution mailing list