<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>I come across this topic and I instantly was overwhelmed by this idea of the <code>Setup Closures</code>. I build a little extension just to test it with UIKit. I thought adding <code>this</code> keyword for <code>Setup Closures</code> was a good idea. If we also could remove <code>this in</code> from the closure it would look good on my opinion.</p>
<pre><code class="swift">protocol SettableType {
init() // designated initializer
}
extension SettableType {
init(@noescape setup: (this: Self) -> Void) {
self.init()
setup(this: self)
}
}
extension UIView: SettableType {}
let view = UIView()
let questionLabel = UILabel() { this in /// <- REMOVE
this.textAlignment = .Center
this.font = UIFont(name:"SomeFontName", size: 72)
this.text = "Hello World"
this.numberOfLines = 0
view.addSubview(this)
}
</code></pre>
<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1449402224132299008" class="bloop_sign"><div><font face="helvetica, arial">— </font></div><div>Regards Adrian<br></div></div> <br><p class="airmail_on">Am 6. Dezember 2015 bei 01:16:31, ilya via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<title></title>
<div dir="ltr">> PROBLEM: With many Apple-supplied classes,
typical initializers fail to fully set up an instance for
use. Here's one example: ...
<div><br></div>
<div>FWIW, I created a configuration operator more then a year ago,
and use it in all of my Swift projects:</div>
<div><br></div>
<div>
<div>let task = NSTask() +=+ {</div>
<div> $0.launchPath = "/usr/bin/mdfind"</div>
<div> $0.arguments = ["kMDItemDisplayName ==
*.playground"]</div>
<div> $0.standardOutput = pipe</div>
<div>}</div>
<div><br></div>
<div>Note you can also use the configured object in the rhs:</div>
<div><br></div>
<div>
<div>let questionLabel = UILabel() +=+ {</div>
<div> $0.textAlignment = .Center</div>
<div> $0.font =
UIFont(name:"DnealianManuscript", size: 72)</div>
<div> $0.text = currentQuestion.questionText</div>
<div> $0.numberOfLines = 0</div>
</div>
<div> view.addSubview($0)</div>
<div>}</div>
<div><br></div>
</div>
<div>This $0. certainly looks ugly and it would be great to be able
to simplify this. I don't llike the following much though
(dot-syntax can be ambiguos here, and using simply a method name is
even worse):</div>
<div><br></div>
<div>
<div>let questionLabel = UILabel() +=+ {</div>
<div> .textAlignment = .Center</div>
<div> .font = UIFont(name:"DnealianManuscript",
size: 72)</div>
<div> .text = currentQuestion.questionText</div>
<div> .numberOfLines = 0</div>
<div> view.addSubview($0)</div>
<div>}</div>
</div>
<div><br></div>
<div>Actually I would be happy with something like</div>
<div><br></div>
<div>
<div>let questionLabel = UILabel() .{</div>
<div> ..textAlignment = .Center</div>
<div> ..font = UIFont(name:"DnealianManuscript", size:
72)</div>
<div> ..text = currentQuestion.questionText</div>
<div> ..numberOfLines = 0</div>
<div> view.addSubview($0)</div>
<div>}</div>
</div>
<div><br></div>
<div>Other thoughts?</div>
<div><br></div>
<div> </div>
</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Q0Y0L54uOhrrHtFzGFlMm5JlViMSyhb7WcyBhJqdl-2FFH6e1qNDZ1tyPWzOlZwbqkHngLBPH8UZ6oBAwvaYDK-2Bfn6g5uWIkEz82LFab3j22HVK5zSuBxORA91q2QuBca7LsK-2Fmo-2BetcbI0ax0MUUSSlCmF7OfgdPuJ33c3-2Fs3mZOEKEsFdtLLJWvEdLDzav21nPmsIRLS9FfGGlIY84eHr3ytux0OlBXIe-2B8QcISOD-2Bs-3D" alt="" width="1" height="1" border="0" style="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;">
_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>