[swift-evolution] [Pitch] Allow closures/default params to satisfy protocol requirements

Matthew Johnson matthew at anandabits.com
Mon Mar 27 09:28:14 CDT 2017


> On Mar 26, 2017, at 8:01 PM, Slava Pestov <spestov at apple.com> wrote:
> 
>> 
>> On Mar 26, 2017, at 5:32 PM, Matthew Johnson <matthew at anandabits.com <mailto:matthew at anandabits.com>> wrote:
>> 
>> 
>> 
>> Sent from my iPad
>> 
>> On Mar 26, 2017, at 7:03 PM, Slava Pestov via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> 
>>>> On Mar 26, 2017, at 11:12 AM, Karl Wagner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>> I’d like to pitch the following two language changes. Both of them are technically possible today if you manually write thunks for the relevant protocol requirements, but it would be nice if we allowed them to be written directly:
>>>> 
>>>> 1) Allow closures to satisfy function requirements in protocols
>>> 
>>> I have mixed feelings about this one because of the argument labels issue.
>>> 
>>> 
>>>> 
>>>> 2) Allow functions with default parameters to satisfy function requirements in protocols
>>>> 
>>> 
>>> This would be an excellent improvement. I don’t think it needs an SE proposal, it is “obvious” how it would work.
>>> 
>>> I would also add the following for full generality:
>>> 
>>> 3) Allow enum cases without payloads to satisfy static read-only property requirements
>>> 4) Allow enum cases with payloads to satisfy static method requirements
>> 
>> I was just thinking about these the other day.  Good to know you're already thinking about them!
> 
> Want to try your hand at implementing them? ;-) Would be a good starter project for diving into Sema and SILGen. I can give pointers and guidance.

I’d love to but alas I have too many projects and too little time already.  :)

> 
> Slava
> 
>> 
>>> 
>>> Slava
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170327/ab365dfa/attachment.html>


More information about the swift-evolution mailing list