Do we have a standard notation for distinguishing static vs instance members?

One things I quite enjoyed in some other languages, was that the community had an established notation for distinguishing static and instance members (functions, properties, etc.). This would be useful in written communication, documentation, and so on.

Some examples:

Language Example class[1] function Example instance method
Objective-C +[MyClass foo], +foo -[MyClass foo], -foo
Ruby MyClass::foo, ::foo MyClass#foo, #foo
Python static MyClass.foo MyClass.foo
Swift ??? MyClass.foo

Do we have an established notation for this? If not, could we decide on one?


  1. Or the equivalent. E.g. Ruby doesn't have class functions, there are just instance methods on a class' metaclass. â†Šī¸Ž

2 Likes

It's worth noting that, in source, MyClass.foo preferentially refers to an unapplied reference to a static method:

extension Int {
  func f() -> Int { 42 }
  static func f() -> Int { 21 }
}
let x = Int.f
x() // 21
1 Like

If we don't have this already my vote would be for the Python version: static MyClass.foo vs MyClass.foo
How do you plan to use this notion?

Note the two members have different types:

class MyClass {
    func foo1(String)
    static func foo2(String)
}

MyClass.foo1 type is: (MyClass) -> (String) -> Void
MyClass.foo2 type: (String) -> Void
1 Like