[swift-evolution] [Review] SE-0088: Modernize libdispatch for Swift 3 naming conventions
Ben Rimmington
me at benrimmington.com
Thu May 12 09:00:03 CDT 2016
<https://github.com/apple/swift-evolution/blob/master/proposals/
0088-libdispatch-for-swift3.md>
## Type Names
I was going to suggest unprefixed type names, but having to qualify both
`Dispatch.Data` and `Foundation.Data` would be an issue. If libdispatch
had originally been part of Foundation, you'd need prefixes anyway:
* DispatchQueue
* NotificationQueue
* OperationQueue
## Quality of Service
Should argument labels and type names match those in Foundation?
* qos: => qualityOfService:
* DispatchQoS => DispatchQualityOfService
Could there be a shared `Swift.QualityOfService` enum?
* QOS_CLASS_DEFAULT = 0x15
* NSQualityOfServiceDefault = -1
The `.unspecified` QoS is not defined in NSQualityOfService.
Would an optional QoS parameter (defaulting to nil) be better?
## Time
The `dispatch_time` function uses a nanoseconds delta, so the operator
overloads taking `seconds: Double` might be ambiguous at the call site.
You could try changing the associated value types of your enum.
```
enum DispatchTimeInterval {
case seconds(Double) // changed from `Int`
case milliseconds(Int64) // changed from `Int`
case microseconds(Int64) // changed from `Int`
case nanoseconds(Int64) // changed from `Int`
}
let _ = DispatchTime.now + 3.5 // ambiguous?
let a = DispatchTime.now + .seconds(3.5)
let b = DispatchTime.now + .milliseconds(3_500)
let c = DispatchTime.now + .microseconds(3_500_000)
let d = DispatchTime.now + .nanoseconds(3_500_000_000)
```
Is the `DispatchTime.now` in your example a type property?
## Data
Should the `DispatchData.append` methods have `contentsOf:` labels?
Or could it conform to the RangeReplaceableCollection protocol?
## Queues
My suggestions for the async/sync methods:
* enqueue(...)
* enqueueAndWaitUntilFinished(...)
-- Ben
More information about the swift-evolution
mailing list