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

Anton Zhilin antonyzhilin at gmail.com
Wed Jul 13 09:17:42 CDT 2016


2016-07-13 15:02 GMT+03:00 Adrian Zubarev via swift-evolution <
swift-evolution at swift.org>:
>
> To answer your question, we still need the metatype to access initializer
> and static member of that type. If we’d drop T.Type completely, we’d lose
> functionality to do so.
>
> protocol A {
>     init()
> }
>
> func foo<T : A>(metatype: T.Type) -> T {
>     return metatype.init()
> }
>
> In such cases, we can always refer to the type directly:

func foo<T : A>(metatype: Type<T>) -> T {
    return T()
}

I would prefer to remove metatypes T.Type completely and replace them with
your somewhat transparent Type<T>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160713/ee76094e/attachment.html>


More information about the swift-evolution mailing list