<div>I think autocapturing can be restricted to non-escaping closures only. For the escaping ones we should think of loosening capture-by-default feature.</div><div><br></div><div>Would works for you, Alex?</div><div><br><div class="gmail_quote"><div>On Mon, 6 Mar 2017 at 19:35 Alex Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg">
<div class="m_1034486365657020563WordSection1 gmail_msg">
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg">I’d be fine losing the ability to pass methods as escaping closures.<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg">I wouldn’t like losing the ability to pass methods as non-escaping closures, because I find this pattern pretty useful:<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> class MyViewController {<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> var records: [Record]<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> var visibleRecords: [Record] { return records.filter(isVisible) }<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> func isVisible(_ record: Record) -> Bool {<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> // some logic here, maybe using other properties of `self`<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p></div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="m_1034486365657020563WordSection1 gmail_msg">
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> }<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"> }<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
<div class="gmail_msg">
<p class="MsoNormal gmail_msg"><b class="gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg">Alex Johnson<u class="gmail_msg"></u><u class="gmail_msg"></u></span></b></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><a href="mailto:ajohnson@walmartlabs.com" class="gmail_msg" target="_blank"><span style="color:#0563c1" class="gmail_msg">ajohnson@walmartlabs.com</span></a><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
</div>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg">ajohnson on Slack</span><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
<p class="MsoNormal gmail_msg"><span style="font-size:11.0pt;font-family:Calibri" class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p>
</div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="m_1034486365657020563WordSection1 gmail_msg"><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in" class="gmail_msg">
<p class="MsoNormal gmail_msg"><b class="gmail_msg"><span style="font-family:Calibri;color:black" class="gmail_msg">From: </span>
</b><span style="font-family:Calibri;color:black" class="gmail_msg"><<a href="mailto:antony.zhilin@gmail.com" class="gmail_msg" target="_blank">antony.zhilin@gmail.com</a>> on behalf of Anton Zhilin <<a href="mailto:antonyzhilin@gmail.com" class="gmail_msg" target="_blank">antonyzhilin@gmail.com</a>><br class="gmail_msg">
<b class="gmail_msg">Date: </b>Saturday, March 4, 2017 at 1:45 AM<br class="gmail_msg">
<b class="gmail_msg">To: </b>"<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>" <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>><br class="gmail_msg">
<b class="gmail_msg">Cc: </b>Alex Johnson <<a href="mailto:AJohnson@walmartlabs.com" class="gmail_msg" target="_blank">AJohnson@walmartlabs.com</a>><br class="gmail_msg">
<b class="gmail_msg">Subject: </b>Re: [swift-evolution] Should explicit `self.` be required when providing method as closure?<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
</div>
<div class="gmail_msg">
<p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p>
</div>
<div class="gmail_msg">
<div class="gmail_msg"></div></div></div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="m_1034486365657020563WordSection1 gmail_msg"><div class="gmail_msg"><div class="gmail_msg">
<p style="margin:1.2em!important" class="gmail_msg">I disagree with dropping function references in general, but I do agree with limiting partially applied method references.<u class="gmail_msg"></u><u class="gmail_msg"></u></p>
<p style="margin:1.2em!important" class="gmail_msg">In <code class="gmail_msg"><span style="font-size:10.0pt;font-family:Consolas;border:solid #eaeaea 1.0pt;padding:0in;background:#f8f8f8" class="gmail_msg">@escaping</span></code> arguments, adding
<code class="gmail_msg"><span style="font-size:10.0pt;font-family:Consolas;border:solid #eaeaea 1.0pt;padding:0in;background:#f8f8f8" class="gmail_msg">self.</span></code> won’t add enough evidence that it actually creates a closure with capture.<br class="gmail_msg">
Even in non-escaping context, I find plain method references odd:<code class="gmail_msg"><span style="font-size:10.0pt;font-family:Consolas;color:#333333;border:solid #cccccc 1.0pt;padding:6.0pt;background:#f8f8f8" class="gmail_msg"><u class="gmail_msg"></u><u class="gmail_msg"></u></span></code></p>
</div></div></div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="m_1034486365657020563WordSection1 gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><p style="margin:1.2em!important" class="gmail_msg">2017-03-04 10:09 GMT+03:00 David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>>:<u class="gmail_msg"></u><u class="gmail_msg"></u></p></div></div></div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple" class="gmail_msg"><div class="m_1034486365657020563WordSection1 gmail_msg"><div class="gmail_msg"><div class="gmail_msg">
<div class="gmail_msg">
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class="gmail_msg">
<p class="MsoNormal gmail_msg" style="margin:1.2em!important">I encountered this precise memory leak in my code a few days ago, so I sympathize. A second solution would be to drop function references. I think a core team member suggested it on another thread.<u class="gmail_msg"></u><u class="gmail_msg"></u></p>
</blockquote>
</div>
<div class="gmail_msg">
<p class="MsoNormal gmail_msg"><span style="font-size:1.0pt" class="gmail_msg"><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p>
</div>
</div></div></div></div>
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></div>