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

Greg Parker gparker at apple.com
Fri Dec 11 20:08:28 CST 2015


> On Dec 11, 2015, at 6:03 PM, 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?

I think you need some explicit marker. Consider the following:

    func f() -> Int {
        return
    }

Is this (1) a generator that returns without yielding anything, or (2) an ordinary function that incorrectly fails to return a value?


-- 
Greg Parker     gparker at apple.com     Runtime Wrangler




More information about the swift-evolution mailing list