[swift-evolution] Small Enhancement Request for Swift Protocol
Matthew Johnson
matthew at anandabits.com
Tue May 17 13:22:22 CDT 2016
Sent from my iPad
> On May 17, 2016, at 1:10 PM, Andrew Trick via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>> On May 14, 2016, at 7:49 AM, Sreejith K R via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Hello All,
>>
>>
>> I would like to suggest an enhancement for the swift protocol would really like this feature to be reviewed.
>>
>> Enhancement Description :
>>
>> Currently it is not possible to invoke the default implementation of a particular protocol (EG: SampleProtocolParent achieved using protocol extension) inside another protocol extention(Eg: SampleProtocolSub) that inherits from the former protocol. Please look into the SampleProtocolSub extension as shown below. Also the same behavior is observed while a class implements the protocol(Please look into the Test class that implements SampleProtocolSub as shown below ).
>>
>> This behavior is something similar to the usage of super keyword while overriding a method.
>>
>> protocol SampleProtocolParent{
>> func testFunction();
>>
>> }
>> extension SampleProtocolParent{
>> func testFunction(){
>> print("hello my super implementation")
>> }
>>
>> }
>> protocol SampleProtocolSub:SampleProtocolParent{
>>
>>
>> }
>>
>> extension SampleProtocolSub{
>> func testFunction(){
>> /* need to call testFunction implementation of the parent SampleProtocolParent as well here. Is this a possible feature ?*/
>> print("hello my current and new implementation")
>> }
>>
>> }
>>
>> class Test:SampleProtocolSub{
>> func testFunction(){
>>
>> /* need to call testFunction implmentaion of the parent SampleProtocolParent as well here. Is this a possible feature ?*/
>> print("hello my current and new new new implementaion")
>> }
>> }
>
> I also want this feature, but haven’t seen any proposed syntax.
> -Andy
How about this (now that we are uncurrying the self parameter):
SampleProtocolParent.testFunction(self)
It's not pretty but it is clear.
>
> _______________________________________________
> 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/20160517/94054b8e/attachment.html>
More information about the swift-evolution
mailing list