[swift-evolution] [Discussion] Seal `T.Type` into `Type<T>`

Anton Zhilin antonyzhilin at gmail.com
Sat Jul 16 03:53:41 CDT 2016


I took some time to overview the whole idea in general, and I must say
(surprisingly) that I don't support it myself.

* Metatypes are still in the language; it turned out that they *must*
remain in the language
* The new primary `Type<T>` struct duplicates semantics and interface of
metatypes
* But it cannot get extensive native support, so it uses `init?(casting:)`
instead of `as` cast, `is(_:)` method instead of `is`, etc
* `Type<T>` does not add new possibilities right now, although the proposal
promises to add reflection to `Type<T>` in the future
* `Mirror` already does reflection. It wraps `Any.Type` statically, which
is a simpler and more suitable model for reflection

I started thinking in a completely different direction:

* Rename metatypes `T.Type` to `Type<T>`
* Rename `T.self` to `T`
* Allow `Type<Type<T>>`
* **Extend `Mirror`** for Swift 4

What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160716/769ef7f5/attachment.html>


More information about the swift-evolution mailing list