<div dir="ltr">Could you explain a little more its a bit confusing ?</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 10:32 AM, Pierre Monod-Broca 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 style="word-wrap:break-word">A groovy closure can have a delegate which replaces `this` as the default receiver. The issue in groovy is that it is not compatible with static compilation, and there is no way to know from the code what is the type of the delegate.<div><br></div><div><div>It works great for DSL. It would work great the Swift Package Manager manifest, among other things.</div></div><div><br></div><div>It could look like this in swift<br><div><br></div><div><font style="font-size:11px" face="Menlo"><span style="color:rgb(53,86,138)">protocol</span> Bar {</font></div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"> <span style="color:rgb(53,86,138)">var</span> someConfig: <span style="color:rgb(195,89,0)">String</span> { <font color="#35568a">get set</font> }</font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo">}</font></div><div style="margin:0px;line-height:normal;min-height:13px"><font style="font-size:11px" face="Menlo"><br></font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"><span style="color:rgb(53,86,138)">func</span> prepareSomething(setup: <span style="color:rgb(53,86,138)">@delegate</span> <span style="color:rgb(195,89,0)">Bar</span> -> () -> ()) {</font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"><font color="#cf8724"> </font><span style="color:rgb(53,86,138)">let</span><font color="#cf8724"> </font>bar<font color="#cf8724"> = </font><span style="color:rgb(195,89,0)">BarImplementation</span>()</font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"> <span style="color:rgb(207,135,36)">// code before</span></font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"> setup(bar)()</font></div><div style="margin:0px;line-height:normal;color:rgb(207,135,36)"><font style="font-size:11px" face="Menlo"><span style="color:#000000"> </span>// code after</font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo">}</font></div><div style="margin:0px;line-height:normal;min-height:13px"><font style="font-size:11px" face="Menlo"><br></font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo">prepareSomething { () -> () <span style="color:rgb(53,86,138)">in</span></font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo"> someConfig = <span style="color:rgb(232,35,0)">"Hello world"</span></font></div><div style="margin:0px;line-height:normal"><font style="font-size:11px" face="Menlo">}</font></div><div style="font-family:Menlo;font-size:11px"><br></div></div><div><div>Where `someConfig` would refer to bar.</div><div><br></div></div><div>
<div>Pierre</div>
</div>
<br></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xV0JY-2FdZMnUMvSFtZnLiBPRTDDOSQf3-2FpH33HYOlBxG0x8OMTNdemFXqF3foFYoqpGnhR8cy-2FlFL4xK8ijX2ylpZvq90E32A79TBFfiQYS5Pn-2Bo59HipCUsCsV7eMemKd8j14RCY6aiJ8QyHIDjLlmHedoUTG5IACcHSAEiGzeoFzcjBqHCbGp9X00IcqPqaDU-2FFTwIwYZpWABXnqMZQq7KoGvwXM01ndVU3G1gj2uw-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><span style="font-size:16px;line-height:19.2px"></span><span style="font-size:12.8px"> Wizard</span><br></div><div><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a></div><div>+44 7523 279 698</div></div></div></div></div></div>
</div>