[swift-corelibs-dev] Proposal: add `noescape` attribute to public API (particularly libdispatch)

Jacob Bandes-Storch jtbandes at gmail.com
Sat Dec 5 16:25:43 CST 2015


On Sat, Dec 5, 2015 at 1:40 PM, Tony Parker <anthony.parker at apple.com>
wrote:

> One topic I wanted to discuss was finding a comprehensive list of API that
> needs the attribute.
>

On this subject, here are some other APIs which could use the annotation.
Again, I think these should be annotated even in the C/Objective-C headers,
so they can benefit C/Objective-C callers as well.

- bsearch, heapsort, qsort, mergesort, psort, and their _b variants

"passing test" methods:
- -[{NSArray,NSOrderedSet} indexOfObjectPassingTest:]
- -[{NSArray,NSOrderedSet} indexesOfObjectsPassingTest:]
- -[{NSArray,NSOrderedSet} indexOfObjectsAtIndexes:passingTest:]
- -[{NSArray,NSOrderedSet} indexesOfObjectsAtIndexes:passingTest:]
- -[SCNNode childNodesPassingTest:]
- -[SCNSceneSource entriesPassingTest:]
- -[AVAudioUnitComponentManager componentsPassingTest:]
- -[NSIndexSet indexPassingTest:]
- -[NSIndexSet indexWithOptions:passingTest:]
- -[NSIndexSet indexesPassingTest:]
- -[NSIndexSet indexesWithOptions:passingTest:]
- -[NSIndexSet indexInRange:options:passingTest:]
- -[NSIndexSet indexesInRange:options:passingTest:]
- -[NSSet objectsPassingTest:]
- -[NSSet objectsWithOptions:passingTest:]
- -[NSDictionary keysOfEntriesPassingTest:]
- -[NSDictionary keysOfEntriesWithOptions:passingTest:]

"using comparator" methods:
- -[NSArray indexOfObject:inSortedRange:options:usingComparator:]
- -[NSArray sortedArrayUsingComparator:]
- -[NSArray sortedArrayWithOptions:usingComparator:]
- -[NSDictionary keysSortedByValueUsingComparator:]
- -[NSDictionary keysSortedByValueWithOptions:usingComparator:]
- -[NSMutableArray sortUsingComparator:]
- -[NSMutableArray sortWithOptions:usingComparator:]
- -[NSMutableOrderedSet sortWithOptions:usingComparator:]
- -[NSMutableOrderedSet sortRange:options:usingComparator:]

 (and some of these have "usingFunction" variants)

"enumerate using block" methods:
- -[NSTableView enumerateAvailableRowViewsUsingBlock:]
- -[SKPhysicsWorld enumerateBodiesAtPoint:usingBlock:]
- -[SKPhysicsWorld enumerateBodiesInRect:usingBlock:]
- -[NSData enumerateByteRangesUsingBlock:]
- -[SCNNode enumerateChildNodesUsingBlock:]
- -[SCNNode enumerateChildNodesWithName:usingBlock:]
- -[NSIndexSet enumerateIndexesUsingBlock:]
- -[NSIndexSet enumerateIndexesWithOptions:usingBlock:]
- -[NSDictionary enumerateKeysAndObjectsUsingBlock:]
- -[NSDictionary enumerateKeysAndObjectsWithOptions:usingBlock:]
- -[NSString enumerateLinesUsingBlock:]
- -[NSString enumerateSubstringsInRange:options:usingBlock:]
- -[{NSArray,NSSet,NSOrderedSet} enumerateObjectsUsingBlock:]
- -[{NSArray,NSSet,NSOrderedSet} enumerateObjectsWithOptions:usingBlock:]
- -[NSIndexSet enumerateRangesUsingBlock:]
- -[NSIndexSet enumerateRangesWithOptions:usingBlock:]
- -[NSIndexSet enumerateRangesInRange:options:usingBlock:]
- -[MPMediaEntity enumerateValuesForProperties:usingBlock:]
- -[NSMetadataQuery enumerateResultsUsingBlock:]
- -[NSMetadataQuery enumerateResultsWithOptions:usingBlock:]

misc:
- -[NSDocument performSynchronousFileAccessUsingBlock:]

Wow, that's more than I expected to find! This is obviously beyond the
scope of just libdispatch, and I think a lot of these should probably
change upstream, in their original frameworks, internally (not something
that community members can really contribute to).

Arguably, the "enumerateXUsingBlock:" pattern should be bridged to Swift as
something SequenceType-ish which can be `for-in`ed.

Jacob Bandes-Storch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20151205/6f83b5e9/attachment.html>


More information about the swift-corelibs-dev mailing list