I’m trying to wrap
public typealias dispatch_data_applier_t = (dispatch_data_t!, Int, UnsafePointer<Void>, Int) -> Bool
public func dispatch_data_apply(data: dispatch_data_t, _ applier: dispatch_data_applier_t) -> Bool
with
func forEach(@noescape body: (UInt8) throws -> ()) rethrows
but since dispatch_data_apply() promises to be @noescape (in the documentation), but doesn’t declare it, I’m stuck. Is there a way to tell the compiler: Really, this will not escape?
/Daniel
jtbandes
(Jacob Bandes-Storch)
January 14, 2016, 8:05am
2
You can work around this by wrapping it with a C function that uses
__attribute__((noescape)).
An example of this is in my proposal "Add @noescape to public library API":
# Add `@noescape` to public library API
* Proposal: [SE-0012](0012-add-noescape-to-public-library-api.md)
* Author: [Jacob Bandes-Storch](https://github.com/jtbandes)
* Review Manager: [Philippe Hausler](https://github.com/phausler)
* Status: **Rejected**
* Decision Notes: [Rationale](https://forums.swift.org/t/rejected-se-0097-normalizing-naming-for-negative-attributes/2854/9)
##### Revision history
* **v1** Initial version
* **v1.2** Updates after component owners review and discussion
## Summary
* Swift provides the `@noescape` declaration attribute which indicates that a closure's execution is guaranteed not to escape the function call.
* clang also provides support for this via a “noescape” attribute, which is automatically imported into Swift as @noescape
* We propose exposing this attribute in CF and Foundation as `CF_NOESCAPE` and `NS_NOESCAPE`
* We also propose applying this declaration to a number of closure-taking APIs in CF and Foundation
This file has been truncated. show original
Jacob Bandes-Storch
···
On Mon, Jan 11, 2016 at 6:29 AM, Daniel Eggert via swift-users < swift-users@swift.org> wrote:
I’m trying to wrap
public typealias dispatch_data_applier_t = (dispatch_data_t!, Int,
UnsafePointer<Void>, Int) -> Bool
public func dispatch_data_apply(data: dispatch_data_t, _ applier:
dispatch_data_applier_t) -> Bool
with
func forEach(@noescape body: (UInt8) throws -> ()) rethrows
but since dispatch_data_apply() promises to be @noescape (in the
documentation), but doesn’t declare it, I’m stuck. Is there a way to tell
the compiler: Really, this will not escape?
/Daniel
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users