[swift-evolution] Would having "MyType.Protocol" to indicate a type's protocols mess anything up?

Robert Bennett rltbennett at icloud.com
Fri Jun 30 20:26:44 CDT 2017


I’m not at a computer to test this, but would this work:

typealias T = P1 & P2
extension C: T {}

Now T is C.Protocol

> On Jun 30, 2017, at 9:17 PM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Jun 30, 2017, at 8:49 PM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
>> 
>> What are you proposing here, I don’t get it?! What role should .Protocol play? .Protocol is an ugly hack in Swift which should be removed anyway. It does more harm than good.
>> 
> I’m not proposing anything right now. I’m asking a question; the proposal that needs the answer can be put off for later.
> 
> Given a type MyType, how can I get a type-alias to the type’s protocols? If MyType conforms to Protocol1 and Protocol2, I would want something like
> 
> 	typealias MyProtocol = Protocol1 & Protocol2
> 
> (and Any if MyType doesn’t conform to any protocols). Does this facility already exist in Swift? I don’t think it does, so I proposed the hybrid “MyType.Protocol” syntax to express the idea.
> 
> If you don’t like the current “.Protocol” syntax, then I guess you don’t like it for this idea. I’m also requesting suggestions for alternate syntax.
> 
> 	#protocols(MyType)
> 
> is an example.
> 
> I guess this should be a separate proposal from my other one.
>> Our revised proposal was deferred from Swift 4:
>> 
>> https://github.com/DevAndArtist/swift-evolution/blob/refactor_existential_metatypes/proposals/0126-refactor-metatypes.md
>> 
> 
>> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT mac DOT com 
> 
> _______________________________________________
> 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/20170630/750bc55d/attachment.html>


More information about the swift-evolution mailing list