[swift-evolution] [Pitch] make @noescape the default
clattner at apple.com
Mon Dec 21 18:43:28 CST 2015
> On Dec 19, 2015, at 4:38 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
> On Sat, Dec 19, 2015 at 12:10 PM, Matthew Johnson via swift-evolution
> <swift-evolution at swift.org> wrote:
>> @noescape is safer because it does not require thinking about lifetime issues for captured objects. My hunch was that @noescape (or @autoclosure with implies @noescape) is also more common. I had a look through the standard library and this is definitely the case there.
>> What does everyone think about making @noescape the default and introducing @escaping (or something similar) to annotate function arguments that do escape the call stack?
> @noescape provides additional guarantees and the optimizer can learn
> to rely on it in future. Thus, it effectively becomes ABI, and you
> can't remove in future versions of the library without breaking the
> ABI. I think adding it should be an explicit decision because of
I agree. This is a very significant API restriction that should be opted-into intentionally. It affects subtyping relationships in protocol conformances and overrides as well.
A different objection to @noescape-by-default is that it makes closures second citizens by default, which makes teaching and learning higher-order functional programming significantly less awesome.
More information about the swift-evolution