[swift-evolution] [Pitch] Adding a Self type name shortcut for static member access
Dave Abrahams
dabrahams at apple.com
Wed Apr 6 11:14:12 CDT 2016
on Wed Apr 06 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:
>> 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.)
Really, no. It's because something's static type is a useful
distinction from its dynamic type, and this clarifies which one you're getting.
> 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.
--
Dave
More information about the swift-evolution
mailing list