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

Jonathan Hise Kaldma info at hisekaldma.com
Fri Dec 11 20:26:06 CST 2015


Shouldn't it be:

func foo() yields -> String

Also +1 on the idea.

/Jonathan

> 12 dec. 2015 kl. 03:18 skrev Jordan Rose via swift-evolution <swift-evolution at swift.org>:
> 
> 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> 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
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> 
> _______________________________________________
> swift-evolution mailing list
> 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/20151212/8a2fc924/attachment.html>


More information about the swift-evolution mailing list