Retro-fitting @noescape

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

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":

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