[swift-evolution] Unify `static` and `class` keywords

Ling Wang an00na at gmail.com
Wed Dec 9 10:41:24 CST 2015

`static` at least has two meanings in Swift:
1. It means `final` for type methods.
2. It also means static storage for stored type properties.

But Swift must mix and match with Objective-C and C so all the existing meanings in these two languages are also inherited in Swift.

Yes, if we all either don’t use it or get used to its usage we won’t feel the design flaws because we won’t think about it. But if we step back and think carefully about it at the design level, we should be able to see the issues. As you advocate in several other proposals like removing ++/— and removing C for-loop, if we have opportunities to do things better in Swift we should do them even if they break old conventions and assumptions.

Also, consider how totally new programmers will feel. I believe they will feel the overloading of meanings on `static`, the dichotomy of static and class methods especially when implementing a static requirement from a protocol, the inconsistency between class and instance member declarations.

- Ling

> On Dec 8, 2015, at 11:37 PM, Chris Lattner <clattner at apple.com> wrote:
>> On Dec 8, 2015, at 7:51 AM, Ling Wang via swift-evolution <swift-evolution at swift.org> wrote:
>> Yes, the `static` is badly overloaded with many different meanings:
>> 1. static storage (old, from C)
>> 2. static linking (old, from C)
>> 3. final (new in Swift)
> static means something like 9 different things in C, including the little known C99 static array parameter size use.  That said, it is not overloaded in swift, and its use in Java and C# is very similar to that in Swift.  Further, again, I have not heard of any problems in practice with the use of the static keyword here.
> -Chris

More information about the swift-evolution mailing list