In Swift, type properties should be identified with the "type" keyword
| Originator: | alexisgallagher | ||
| Number: | rdar://17302402 | Date Originated: | 2014-06-13 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode6-Beta |
| Classification: | Enhancement | Reproducible: |
Summary: The Swift book describes the concept of "type properties", as opposed to instance properties. A type property is a property of a class, or a struct. When it's the property of a class, it is identified with the keyword "class". When it is the property of a struct, it is identified with the keyword "static". I'd like to suggest that a type property always be identified with the keyword "type". Why? One reason is clarity. "static" is a bad choice because it's a weird C vestige describing storage duration, which is out of place in Swift's ARC-based memory model. "class" is a bad choice because it is only accurate for class types. "type" is a good choice because these are, as the language spec itself says, "type properties"! Another reason is pragmatic. Right now, if you want to change a struct into a class (or vice versa), you need to perform a pointless search and replace swapping static for class (or vice versa). If both classes and structs just used the keyword "type", then you would not have to make this change. Steps to Reproduce: 1. Define a struct with some type properties 2. Make it into a class instead Expected Results: In simple cases, I only need to replace "struct" with "class" Actual Results: I need to go and replace the counter-intuitive keyword "static" with another keyword "class" Version: Xcode6-Beta Notes: Configuration: Xcode6-Beta Attachments:
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!