Swift "static" should be changed

Originator:brent
Number:rdar://17297012 Date Originated:12-Jun-2014 08:23 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta (6A215l)
Classification:Enhancement Reproducible:Always
 
Summary:
I love that class variables and methods are, for once in my life, actually marked with the “class” keyword in Swift. Unfortunately, this doesn’t extend to structs, enums, and protocols, which all use “static”.

This inconsistency bothers me. I know a lot of people have called for you to use “static” everywhere, but I think that would be a mistake. “static” has never captured what type variables are *for* very well; instead it captures a detail of how their storage is allocated. It’s especially egregious on type methods, which are no more “static” than instance methods.

Basically, “static” was a cute trick C++ used to avoid requiring the language reserve another keyword. It’s survived far too long on sheer inertia. It’s past time that it be put down.

I think that type variables and methods in a struct should be marked “struct”, and ones in an enum should be marked “enum”. Protocols are a tougher case; the final variable or method is on the types conforming to the protocol, not the protocol itself, so “protocol” isn’t really appropriate here. Either any of the keywords—“class”, “enum”, or “struct”—should be allowed, or the keyword “type” should be used.

Alternately, “type” should just be used everywhere—classes, structs, enums, and protocols. The documentation calls them “type variables” and “type methods”, after all.

Just please, spare me “static”.

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!