[swift-evolution] [Pitch] Adding a Self type name shortcut for static member access

Brent Royal-Gordon brent at architechies.com
Wed Apr 6 05:07:09 CDT 2016


> Alternatively, why is it ‘dynamicType’ and not just ‘type’?

I suspect this has something to do with the 27 methods in various OS X frameworks named `type`. (To be fair, 17 of those are in WebKit's DOM classes.)

What I'm less sure about is why it's not a free function instead. Other than the `dynamicType` and `self` pseudo-properties, I'm not aware of any members which are present on all types. We might be better off making `dynamicType` a free `typeof(_:)` function (or should it be `type(of:)`? are `sizeof` and friends changing?) and `self` a free `identity(_:)` function; these would make them non-magical parts of the language, which would be kind of neat.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list