[swift-evolution] Extending trailing closure sugar similar to property accessors

Eric Summers eric_summers at icloud.com
Thu Nov 2 19:58:07 CDT 2017


A similar problem exists with property accessors.  Although you could call those keywords, they will probably be extensible when behaviors are introduced leading to a similar situation.  It can be worked around by making the priority of argument labels higher then function calls within the curly brackets.

Eric

> On Nov 2, 2017, at 8:51 PM, Slava Pestov via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> 
>> On Nov 2, 2017, at 4:04 PM, Eric Summers via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> // A sugar similar to property accessors for multiple trailing closures:
>> foobar(a: 1, b: 2) {
>>     completionBlock { x, y in
>>     // ...
>>     }
>>     failureBlock { i, j in
>>     // ...
>>     }
>> }
> 
> This syntax is ambiguous. Are you passing in two trailing closures to foobar(), or a single trailing closure, inside which you call two top-level functions, completionBlock and failureBlock?
> 
> Slava
> 
> _______________________________________________
> 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/20171102/6a621220/attachment.html>


More information about the swift-evolution mailing list