<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I'm probably missing the point here, so apologize in advance. Instead of reducing a function with an n-arity set of arguments to a partially applied function with (m|m<n)-arity set of arguments, it's building a functional application and applying that to an arbitrary receiver.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>`UIView.removeFromSuperview(receiver) `</div><div class=""><br class=""></div><div class="">defines</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>`receiver.removeFromSuperview`</div><div class=""><br class=""></div><div class="">which can then be applied with whatever arguments, () in this case.</div><div class=""><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>`UIView.removeFromSuperview(receiver)()` aka `receiver.removeFromSuperview()`</div></div><div class=""><br class=""></div><div class="">With mapping, you can do:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> v = <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span>()</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">...</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">).</span>forEach<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">{</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">v</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>addSubview<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">())}</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// You can apply each subview as a receiver, returning a function</div><div class=""><span style="color: rgb(187, 44, 162);" class="">let</span><span style="color: rgb(0, 0, 0);" class=""> applied = </span><span style="color: rgb(79, 129, 135);" class="">v</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(112, 61, 170);" class="">subviews</span><span style="color: rgb(0, 0, 0);" class="">.</span>map<span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(112, 61, 170);" class="">UIView</span><span style="color: rgb(0, 0, 0);" class="">.</span>removeFromSuperview<span style="color: rgb(0, 0, 0);" class="">) </span></div></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// [(Function), (Function), (Function), (Function), (Function)]</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><div style="margin: 0px; line-height: normal;" class="">// And then you an execute them in forEach</div><div class=""><span style="color: rgb(61, 29, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(79, 129, 135);" class="">v</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(112, 61, 170);" class="">subviews</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(112, 61, 170);" class="">count</span><span style="color: rgb(0, 0, 0);" class="">) </span>// 5</div></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">v</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">subviews</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>map<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>removeFromSuperview<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">).</span>forEach<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">{$0()}</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">v</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>subviews<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>count<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// 0</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class=""><br class=""></span></div><div class="">The whole map/forEach could be defined down to apply in a possible language extension, as I mentioned before.</div><div class=""><br class=""></div><div class="">-- E, who apologizes for really not getting this</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Mar 13, 2016, at 1:21 PM, Brandon Williams <<a href="mailto:mbw234@gmail.com" class="">mbw234@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I think this highlights some of the confusion around the current curried convention. Void methods are curried as A -> () -> (), which means you would use it like:</div><div class=""><br class=""></div><div class=""><div class="">UIView.removeFromSuperview # => UIView -> () -> ()</div><div class="">UIView.removeFromSuperview(view) # => () -> ()</div><div class="">UIView.removeFromSuperview(view)() #> ()</div></div><div class=""><br class=""></div><div class="">I find this confusing because removeFromSuperview reads as an action, yet UIView.removeFromSuperview(view) does not perform the action but rather is an action itself that requires a further invocation ().</div><div class=""><br class=""></div><div class="">With arguments flipped we would have:</div><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><div class="">UIView.removeFromSuperview # => () -> UIView -> ()</div><div class="">UIView.removeFromSuperview() # => UIView -> ()</div><div class="">UIView.removeFromSuperview()(view) #> ()</div></div><div class=""><br class=""></div><div class="">It now reads to me that UIView.removeFromSuperview() is the action that will do the removing, and UIView.removeFromSuperview()(view) is applying the action to a view.</div><div class=""><br class=""></div><div class="">I don’t advocate using removeFromSuperview in this manner, but if one were to I believe the latter convention is easier to reason about without having to look up types in a playground (as I had to do a few times to write this :P)</div><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, Mar 13, 2016 at 1:50 PM Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="">
> On Mar 13, 2016, at 11:30 AM, Stephen Celis <<a href="mailto:stephen.celis@gmail.com" target="_blank" class="">stephen.celis@gmail.com</a>> wrote:<br class="">
><br class="">
>> On Mar 13, 2016, at 1:18 PM, Erica Sadun <<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>> wrote:<br class="">
>><br class="">
>> Since removeFromSuperview doesn't take a UIView argument, it sounds like what you're looking for is<br class="">
>> something that acts like "apply", to apply a lambda/closure/selector/whatever to each member of a collection.<br class="">
>><br class="">
>> view.subviews.apply(UIView.removeFromSuperview)<br class="">
>><br class="">
>> -- E<br class="">
><br class="">
> This is what `forEach` currently does with the existing curried static syntax, right?<br class="">
><br class="">
> I was more interested in the implications of an example brought up in the OP:<br class="">
><br class="">
> frames.map(CGRect.insetBy(-10, -10))<br class="">
><br class="">
> - Stephen<br class="">
<br class="">
forEach currently does f(x).<br class="">
apply would do x.f()<br class="">
<br class="">
-- E<br class="">
<br class="">
_______________________________________________<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><br class="">
</blockquote></div></div></div>
</div></blockquote></div><br class=""></body></html>