<div dir="ltr"><div class="gmail_default" style="font-family:comic sans ms,sans-serif;color:#274e13">+1</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><br><div>All the best,</div><div><br></div><div>Nicholas</div><div><br></div><div>Linked in:</div><div><font size="2"><a href="http://lnkd.in/328U22" target="_blank">http://lnkd.in/328U22</a></font><br></div><div><br></div></div></div></div>
<br><div class="gmail_quote">On Mon, May 16, 2016 at 7:27 AM, Dave Abrahams via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
on Fri May 13 2016, Joe Groff <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
<br>
>> On May 13, 2016, at 9:13 AM, Rob Napier via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> Currently if a closure takes a value, it requires "_ in" to note<br>
>> that the value is ignored. This makes sense in many cases, but<br>
>> creates a bit of a mess in the case of an empty, void-returning<br>
><br>
>> closure:<br>
>><br>
>> doThing(withCompletion: { _ in })<br>
>><br>
>> I'd like to suggest that the compiler promote the empty closure<br>
>> literal {} to any void-returning closure type so that this could be<br>
>> written:<br>
>><br>
>> doThing(withCompletion: {})<br>
>><br>
>> This encourages the use of empty closures over optional closures,<br>
>> which I think is open for debate. In general I try to avoid<br>
>> optionals when they can be precisely replaced with a non-optional<br>
>> value. Furthermore, most Cocoa completion handlers are not optional.<br>
>><br>
>> The alternative is to not do this, but encourage that any closure<br>
>> that could reasonably be empty should in fact be optional. I would<br>
>> then want Cocoa functions with void-returning closures to be<br>
>> imported as optionals to avoid "{ _ in }".<br>
><br>
> +1. In general, I think we should allow implicit arguments, without<br>
> requiring the closure to use all the implicit $n variables like we do<br>
> today. These should all be valid:<br>
><br>
> let _: () -> () = {}<br>
> let _: (Int) -> () = {}<br>
> let _: (Int, Int) -> Int = { 5 }<br>
> let _: (Int, Int) -> Int = { $0 }<br>
> let _: (Int, Int) -> Int = { $1 }<br>
<br>
</div></div>+1<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
-Dave<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>