[swift-evolution] Remove forEach?
Stephen Celis
stephen.celis at gmail.com
Wed Dec 9 06:40:22 CST 2015
> On Dec 8, 2015, at 5:13 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>
> Another direction you might take this is to make it a type annotation on the function type, like throws, so forEach has a type like this:
>
> func forEach(body: (Element) breaks -> ())
>
> and a closure that `breaks` has nonlocal behavior for break/continue/return (and is implied to be noescape and void-returning, I guess).
This is really interesting. Ruby provides similar functionality with its lambda vs. proc, but a type annotation is much more understandable. It could also imply @noescape automatically:
func forEach(@canbreak body: Element -> Void)
Stephen
More information about the swift-evolution
mailing list