[swift-evolution] Inquiry: Improved Composability of stdlib Collections?

plx plxswift at icloud.com
Sat Dec 5 13:34:56 CST 2015

Swift’s standard library's core collections' value-like, copy-on-write behavior is handy in the small, but they compose rather poorly with each other: if you have e.g. [K:Set<V>], and plan to mutate the “inner" sets, it seems at present as if there is no way to avoid an unnecessary transient copy of each set for each mutation you perform upon it.

Various workarounds/solutions exist but all are full of unfortunate tradeoffs and/or limited further composability; in concrete cases you can do alright, but it’s hard to craft a generic solution that doesn’t inadvertently reintroduce the problem you started-out trying to solve.

Is anything currently on the roadmap to address this specifically — whether optimizer improvements, extended APIs, implementation adjustments, a `borrow` construct, or some other approach?

More information about the swift-evolution mailing list