Why do closures require an explicit `self` when they're all non-escaping by default in Swift 3?

后端 未结 3 2047
北海茫月
北海茫月 2020-12-03 11:10

I\'ve noticed that in Swift 2.2, closures marked as non-escaping with @noescape do not require an explicit self. In Swift 3, all closures are non-e

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 11:33

    Stored closures are considered escaping by default, even when they aren't really. There's no way to mark them non-escaping so we're stuck like this until they add @noescape back to the language, which they may or may not do. See this discussion on the swift-evolution mailing list.

提交回复
热议问题