[swift-evolution] AnyProtocol proposal
Joao Nunes
joao3001 at hotmail.com
Wed Feb 17 15:20:03 CST 2016
I didn’t get you 100%.
But If you are saying that the programmer is providing the API then yes.
João
> On 17 Feb 2016, at 23:00, David Waite <david at alkaline-solutions.com> wrote:
>
> 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 <mailto: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 <mailto: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/c42eddfc/attachment-0001.html>
More information about the swift-evolution
mailing list