[swift-evolution] [Proposal] Separate protocols and interfaces

Matthew Johnson matthew at anandabits.com
Sun Jan 3 11:18:28 CST 2016



Sent from my iPad

> On Jan 3, 2016, at 10:53 AM, David Waite via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I like this, and had considered proposing something similar.
> 
> Points:
> I would have chose to leave protocol to mean the dynamically dispatch-able type declaration, as that is what it indicates in Objective-C. Your proposal would cause every Objective-C protocol to now be considered an interface in Swift terms.
> 
> Some discussion on this list makes me think that you might instead have a modifier for declaring statically dispatched, existential protocols - e.g. “existential protocol SequenceType { … }”

The problem with *requiring* distinct syntax for protocols that are intended to be used as existential a is that it is a stated goal to expand the kinds of protocols which can be used as existentials.  In other words, the set of protocols that can be used as existentials is a moving target that is likely to grow substantially in the future.

I would be comfortable with some kind of optional assertion that a protocol can be used as an existential but probably not comfortable with anything more than that.

> 
> Also, note not all usage of Self need be disallowed in dynamically dispatch-able types today:
> 
> protocol Test { 
>      func foo() -> Self 
> }    
> 
> var t:Test? // legal, I assume on purpose due to the covariance of the return type
> 
> -DW
> 
>> On Jan 3, 2016, at 7:48 AM, Антон Жилин via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Introduction of interfaces will clean up the current blend of static and dynamic protocols, and solve at least three popular issues.
>> Please see:
>> https://github.com/Anton3/swift-evolution/blob/master/proposals/0000-introducing-interfaces.md
>>  _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> 
> _______________________________________________
> 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/20160103/80995259/attachment.html>


More information about the swift-evolution mailing list