[swift-evolution] [Review] SE-0088: Modernize libdispatch for Swift 3 naming conventions

Matt Wright mww at apple.com
Thu May 12 13:03:33 CDT 2016


> On May 12, 2016, at 7:00 AM, Ben Rimmington via swift-evolution <swift-evolution at swift.org> wrote:
> 
> <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?

Are you talking about ambiguity at a compiler level, or in human-reading? The other four examples are an addition with an enum type, the first one is a double. There’s no compiler ambiguity here.

> 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?

DispatchTime.now() is a function that returns the current time. The subsequent examples are typos (now() became a method quite late in the proposal’s development) and I’ll fix it up before pushing a v2 proposal that’s fixed up a lot of the typos that arose from late changes.

> 
> ## 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
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list