[swift-evolution] [Revision] [Pitch] Rename `T.Type`

Anton Zhilin antonyzhilin at gmail.com
Fri Jul 22 10:03:57 CDT 2016

2016-07-22 17:32 GMT+03:00 Karl <razielim at gmail.com>:

> I wouldn’t be surprised if there are less than a handful of people outside
> of the Swift team who understand what .Protocol means.
> Most of us just want to create generic objects based on their conformance
> to an initialiser in a protocol:
> protocol Constructable {
> init()
> }
> func construct<C:Constructable>() -> C {
> return C()                                               // ERROR
> }
In your example, there is no problem, because we can disambiguate based on
return type:

let c = construct() as SomeConstrictible

Metatypes are only really needed, when target type would not appear in the
signature otherwise.
And I kind-of understand the decision of not adding explicit generic
function specialization, because otherwise there would be double
specialization in generic constructors, like this:

struct Example<T> {

And that would look awful. If I'm not mistaken, such initializers exist in
the standard library.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160722/9bac0144/attachment.html>

More information about the swift-evolution mailing list