[swift-evolution] Proposal: add `noescape` attribute to public API (particularly libdispatch)
jtbandes at gmail.com
Sat Dec 5 14:53:05 CST 2015
There are several functions in public API, such as dispatch_sync and
dispatch_apply, which do not allow their block parameters to escape the
However, they are not currently exposed to Swift as @noescape, meaning that
users are required to specify "self." or "[weak self]" in their closures.
The instances I can think of:
- dispatch_block_perform (thanks to Pierre Habouzit for pointing this out)
I provided a preliminary implementation at
https://github.com/apple/swift-corelibs-libdispatch/pull/6, but it needs
refinement. Tony Parker mentioned commented that there might be similar
changes to make for the swift-corelibs-foundation project.
Question: does __attribute__((noescape)) have the same meaning when applied
to C function pointers? Namely, does Swift understand @noescape as it
applies to @convention(c)?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution