[swift-evolution] Changing postfix "self" to something clearer like "type"

Greg Parker gparker at apple.com
Thu Dec 17 17:43:54 CST 2015


> On Dec 17, 2015, at 9:47 AM, Jordan Rose via swift-evolution <swift-evolution at swift.org> wrote:
> 
> We have that; it's ".dynamicType". That's not really related to ".self".
> 
> Swift's model is like Objective-C's: if you want to refer to a type as a value, you have to call it out specifically. Objective-C chose "[SomeType class]" for this, but "[SomeType self]" actually works as well.

Objective-C's `[SomeClass class]` is wrong in a formal sense. `[object class]` returns the object's class, but `[SomeClass class]` does not return the class's class (i.e. its metaclass). `[SomeClass self]` is the formally more consistent one.


-- 
Greg Parker     gparker at apple.com     Runtime Wrangler




More information about the swift-evolution mailing list