Swift standard libary should use more verbose generic type names
| Originator: | brent | ||
| Number: | rdar://17651011 | Date Originated: | 12-Jul-2014 01:30 AM |
| Status: | Closed/Behaves Correctly | Resolved: | 15-Jul-2014 09:09 AM |
| Product: | Developer Tools | Product Version: | Xcode6-Beta3 (6A254o) |
| Classification: | Enhancement | Reproducible: | Always |
Summary: The Swift standard library is rife with generic types like T, U, C, and S. Due to the complexity of some of the declarations—I’ve seen some cases where the angle brackets are more than 70 characters apart—it’s often easy to forget what a given type means by the time you reach it. The standard library should instead favor longer names that better describe the type when viewed in isolation. Steps to Reproduce: 1. Start typing join(). 2. Forget what order the arguments go in. 3. Command-click to view the declaration. 4. Try to read the parameter list. Expected Results: The names of the types in the parameter list make it reasonably clear what each parameter’s type is—for instance, CollectionType and SequenceType, or even CollectionType and SequenceOfCollectionsType. Actual Results: The names of the types are C and S, which is briefer but more opaque. Notes: The specific convention I use here—CollectionType, for instance—might be rejected because it’s too similar to “Collection.Type”, but if so, please don’t throw out the baby with the bathwater. This is a case where brevity is hurting clarity. -------------------------------------------------------------------------------- Engineering has determined that this issue behaves as intended based on the following: We don't think verbosity of the sort requested improves things at all: func join< ExtensibleCollectionType : ExtensibleCollection, SequenceType : Sequence where SequenceType.GeneratorType.Element == ExtensibleCollectionType> (separator: ExtensibleCollectionType, elements: SequenceType) -> ExtensibleCollectionType Naming things according to their role is arguably less-bad, but we still don't think it helps with overall readability. Others may disagree; this is a judgement call. func join< Separator : ExtensibleCollection, Fragments : Sequence where Fragments.GeneratorType.Element == Separator> (separator: Separator, fragments: Fragments) -> Separator We are now closing this bug report. If you have questions regarding the resolution of this issue, please update your bug report with that information. Please be sure to regularly check new Apple releases for any updates that might affect this issue.
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!