[swift-evolution] AnyProtocol proposal
David Waite
david at alkaline-solutions.com
Wed Feb 17 15:00:22 CST 2016
So if I understand, the goal is to restrict safe/functional behavior when it doesn’t align with the intentions of how an API was intended to be used?
-DW
> On Feb 17, 2016, at 12:37 PM, João Nunes via swift-evolution <swift-evolution at swift.org> wrote:
>
> The code is for a delegate. Thus it needs a protocol not a class.
>
> If you use a class and not a protocol, your delegate wont be able to subclass any other class to implement the "protocol" because it is a class.
>
> The same applies if the uitableview delegate was declared as a class. You couldn't subclass a viewcontroller and still conform to the tableview delegate protocol.
>
>
> Joao
>
> Sent from my iPhone
>
> On 17 Feb 2016, at 21:12, Sune Foldager <cyano at me.com <mailto:cyano at me.com>> wrote:
>
>>
>>> On 17 Feb 2016, at 18:59, João Nunes via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>> In the example given. How would you restrict the generic type to a protocol without the use of AnyProtocol ?
>>
>> But what would you gain from restricting to just protocols? What could go wrong if someone passed in a class?
>>
>> -Sune
>>
> _______________________________________________
> 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/20160217/bd71cd7a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160217/bd71cd7a/attachment.sig>
More information about the swift-evolution
mailing list