[swift-evolution] [Draft] Dictionary & Set Enhancements

David Hart david at hartbit.com
Sun Apr 2 16:03:22 CDT 2017


Hello,

This proposal is looking great! But we need to move fast as the time for proposal is pretty much over. Just a few points:

SR-922

Just wanted to point out again what Nate alluded to in the proposal: all functions which take as argument a Sequence can cause weird compilation errors because of the way the type-system handles tuple labels:

let a = [1, 2, 3, 4, 5]
let b = a.map({ ($0.description, $0 * 2) })
let c = Dictionary(b)
// error: generic parameter 'Key' could not be inferred

And requires specifying the tuple labels to compile:

let a = [1, 2, 3, 4, 5]
let b = a.map({ (key: $0.description, value: $0 * 2) })
let c = Dictionary(b)

There is a bug report about this issue SR-922 <https://bugs.swift.org/browse/SR-922>  I had missed it when reading the proposal initially, so just wanted to point people to it again.

first and last

I also don’t think that first and last don’t pull their weight as global functions and I’m not a fan of MergeCollisionStrategy either. I’m perfectly okay with using { $0 } and { $1 }.

Thanks!
David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170402/c2392cbe/attachment.html>


More information about the swift-evolution mailing list