<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 14 Nov 2017, at 20:41, Wallacy &lt;<a href="mailto:wallacyf@gmail.com" class="">wallacyf@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">Em ter, 14 de nov de 2017 às 17:02, Mike Kluev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; escreveu:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class="">On Mon, 13 Nov 2017 22:30:25 +0100 David Hart &lt;<a href="mailto:david@hartbit.com" target="_blank" class="">david@hartbit.com</a>&gt; wrote:<br class=""></div></div><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">&gt; On 13 Nov 2017, at 05:52, Slava Pestov &lt;<a href="mailto:spestov@apple.com" target="_blank" class="">spestov@apple.com</a>&gt; wrote:<br class="">&gt;<br class="">&gt;&gt; On Nov 12, 2017, at 8:11 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">&gt;&gt;<br class="">&gt;&gt; By analogy with the current closure syntax, the capture list ought to go somewhere before the parameter list, in one of these slots:<br class="">&gt;&gt;<br class="">&gt;&gt; 1.&nbsp; &nbsp;func fn&lt;T&gt;[foo, bar](param: T) throws -&gt; T where T: Equatable { … }<br class="">&gt;&gt; 2.&nbsp; &nbsp;func fn[foo, bar]&lt;T&gt;(param: T) throws -&gt; T where T: Equatable { … }<br class="">&gt;&gt; 3.&nbsp; &nbsp;func [foo, bar] fn&lt;T&gt;(param: T) throws -&gt; T where T: Equatable { … }<br class="">&gt;&gt; 4.&nbsp; &nbsp;[foo, bar] func fn&lt;T&gt;(param: T) throws -&gt; T where T: Equatable { … }<br class="">&gt;&gt;<br class="">&gt;&gt; Of these options, I actually think #4 reads best; 1 and 2 are very cluttered, and 3 just seems weird. But it seems like the one that would be easiest to misparse.<br class="">&gt;<br class="">&gt; Another option that reads nicely IMHO is<br class="">&gt;<br class="">&gt; func fn&lt;T&gt;(param: T) throws -&gt; T where T : Equatable [foo, bar] { … }<br class="">&gt;<br class="">&gt; I think #4 is ambiguous with array literals unfortunately.<br class=""></blockquote></div></div></div></div><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"></blockquote><div class=""><br class=""></div><div class="">adding to the list of options:</div><div class=""><br class=""></div><div class="">6. func fn&lt;T&gt;(param: T) throws -&gt; T where T: Equatable [foo, bar]&nbsp;{ … }</div><div class=""><br class=""></div><div class="">otherwise +1 to #1 and to the one in proposal. also see about #4 below.</div><div class=""><br class=""></div><div class="">plus, if 90%+ of use cases in practice would be [weak self] -- (the only examples shown in the proposals FTM) -- i would strongly consider this syntax sugar in addition to a generic notation:</div><div class=""><br class=""></div><div class="">weak func fn&lt;T&gt;(param: T) throws -&gt; T where T: Equatable { … }</div><div class=""><br class=""></div><div class="">works with "unowned" as a bonus.</div><div class=""><br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">weak func&nbsp; to imply [weak self] is a good idea.&nbsp;</div></div></div></div></blockquote><div><br class=""></div>I’d be very hesitant to introduce this syntax:</div><div><br class=""></div><div><ul class="MailOutline"><li class="">it’s new syntax, so it comes with a complexity tax (it isn’t naturally obvious what it means for a func to be weak)</li><li class="">it’s only sugar for the capture of self</li><li class="">it doesn’t transpose well to local closures</li></ul><div class=""><br class=""></div><div class="">On the other hand, the proposal attempts to resolve the problems mentioned in the Motivation section by introducing as little syntax as possible. And the little it does (capture lists) is no similar to closures that increased complexity tax is fairly low.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote"><div class="">weak func foo() {</div><div class="">&nbsp; self?.bar();</div><div class="">}</div><div class=""><br class=""></div><div class=""><div class="">unowned func foo() {</div><div class="">&nbsp; self.bar();</div><div class="">}</div><div class=""><br class=""></div><div class="">Maybe this to:</div><div class=""><br class=""></div>onChange = weak { self?.bar() }<br class="inbox-inbox-Apple-interchange-newline"></div><div class=""><br class=""></div><div class=""><div class="">But we still have the problem using capture list.</div><br class="inbox-inbox-Apple-interchange-newline"></div><div class="">And to avoid inconsistencies, I would leave the same way as the proposal.<br class=""></div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46);" class=""> <span class="inbox-inbox-pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="inbox-inbox-pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">local</span>() { [<span class="inbox-inbox-pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">weak</span> <span class="inbox-inbox-pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">self</span>] <span class="inbox-inbox-pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">in</span>
            <span class="inbox-inbox-pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">self</span><span class="inbox-inbox-pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">?</span>.<span class="inbox-inbox-pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">bar</span>()
        }</pre></div><div class=""><br class=""></div><div class="">There's no perfect solution. And in this works fine today.</div><div class=""><br class=""></div><div class="">&nbsp;<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""></div><div class="">if implement this sugar than some variation of #4 looks appealing to have these capture things close.</div></div></div></div></div><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Mike</div><div class=""><br class=""></div></div></div></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote></div></div></div></blockquote></div><br class=""></body></html>