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

David Hart david at hartbit.com
Fri Jul 22 10:51:02 CDT 2016


Isn't the solution to a lot of these issues allowing explicit generalization instead of this meta type business?

> On 22 Jul 2016, at 17:03, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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> {
>     init<U>()
> }
> Example<Int><Double>
> 
> And that would look awful. If I'm not mistaken, such initializers exist in the standard library.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160722/721686fc/attachment.html>


More information about the swift-evolution mailing list