Swift.String, Array, and Set should support a common protocol for mutation

Originator:brent
Number:rdar://19771884 Date Originated:09-Feb-2015 02:24 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6.3-Beta (6D520o)
Classification:Enhancement Reproducible:Always
 
Summary:
Swift.String, Swift.Array, and Swift.Set should all conform to a single protocol supporting the following:
* Enumerating the elements in the collection
* Removing elements found by enumerating
* Adding elements (appending in an ordered collection)
* Testing for the presence of an element

Currently, String and Array conform to ExtensibleCollectionType, but Set does not.

Steps to Reproduce:
1. Download and add my CollectionDictionary type to a project: <https://gist.github.com/brentdax/f8a856ccd9a9fa5ab86f>.
2. Extend it to support a Value type of Swift.Set in addition to Swift.Array and Swift.String.

Expected Results:
Doing so is possible because Swift.Set conforms to either ExtensibleCollectionType or a similar protocol with less stringent “informal” requirements.

Actual Results:
Doing so is not possible because Array, String, and Set do not support any common protocols which allow mutation.

Notes:
There are certainly semantic and time complexity differences between Swift.Set’s insert() and the other types’ append() methods, but in many use cases, these differences don’t matter. We also need a way to handle these sorts of situations.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!