Hi David,

> On Aug 26, 2017, at 15:36, David Zarzycki <zarzy...@icloud.com> wrote:
> 
> Without going into details, it looks like the Swift wrappers for 
> dispatch_time_t are very, very broken. In short, dispatch_time_t (in the C 
> world) is intentionally documented as an opaque type, but the Swift wrappers 
> assume otherwise and jump to wrong conclusions about the implementation of 
> the type. What this means in practice is that you should avoid the 
> DispatchTime comparison APIs for now.

They’re not *that* opaque, they’re here:
<https://github.com/apple/swift-corelibs-libdispatch/blob/0fd5a69ee5f9597aeaff8aa3f48021ced022db15/src/time.c#L93>
 and
<https://github.com/apple/swift-corelibs-libdispatch/blob/0fd5a69ee5f9597aeaff8aa3f48021ced022db15/src/time.c#L136>

In any event, the DispatchTime and DispatchWallTime wrappers do not let you 
initialize them from a raw value and, as such, avoid the duality of 
dispatch_time_t.

In my example, the runtime is probably not running the comparator it’s supposed 
to
(the one at 
https://github.com/apple/swift/blob/92f750aa3c3c4dce47eb55068850f3d1127b16bd/stdlib/public/SDK/Dispatch/Time.swift#L73).
 We can observe what the values are: some int in the range 1..<(2^63), and 
2^64-1. The latter is always greater than the former, yet we’re getting `false` 
from a less-than operator. Strange.

Guillaume Lessard


_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to