<div dir="ltr">This is a common pattern for initialisers at the moment:<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span style="">class</span><span style="color:rgb(0,0,0)"> Foo</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="">{</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> foo : </span><span style="color:rgb(112,61,170)">String</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> bar : </span><span style="color:rgb(112,61,170)">String</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> barCount : </span><span style="color:rgb(112,61,170)">Int</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> baz : </span><span style="color:rgb(112,61,170)">Int</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style=""></span><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">init</span><span style="">(foo: </span><span style="color:rgb(112,61,170)">String</span><span style="">, bar: </span><span style="color:rgb(112,61,170)">String</span><span style="">, baz: </span><span style="color:rgb(112,61,170)">Int</span><span style="">)</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span>{</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(187,44,162)">self</span><span style="">.</span><span style="color:rgb(79,129,135)">foo</span><span style=""> = foo</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(187,44,162)">self</span><span style="">.</span><span style="color:rgb(79,129,135)">bar</span><span style=""> = bar</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(187,44,162)">self</span><span style="">.</span><span style="color:rgb(79,129,135)">baz</span><span style=""> = baz</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:rgb(0,0,0)"><span class="" style="white-space:pre">                </span></span><span style="color:rgb(79,129,135)">barCount</span><span style="color:rgb(0,0,0)"> = bar.</span><span style="">characters</span><span style="color:rgb(0,0,0)">.</span><span style="">count</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span>}</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">













</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="">}</span></p></div><div><br></div><div>This involves a lot of using &#39;self.&#39;. For those who prefer not to use &#39;self.&#39; explicitly everywhere, this is probably the main place it gets used. It&#39;s a lot of boilerplate code.</div><div><br></div><div>How would it be if, like default variables, we could pack some of that information into the argument tuple, and unify parameters with properties immediately?</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span style="">class</span><span style="color:rgb(0,0,0)"> Foo</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="">{</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> foo : </span><span style="color:rgb(112,61,170)">String</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> bar : </span><span style="color:rgb(112,61,170)">String</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> barCount : </span><span style="color:rgb(112,61,170)">Int</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">let</span><span style=""> baz : </span><span style="color:rgb(112,61,170)">Int</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style=""></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(187,44,162)">init</span><span style="">(</span><span style="color:rgb(187,44,162)">self</span><span style="">.foo: String, </span><span style="color:rgb(187,44,162)">self</span><span style="">.bar: String, </span><span style="color:rgb(187,44,162)">self</span><span style="">.baz: Int)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span>{</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">                </span>barCount = bar.characters.count</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style=""><span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="">}</span></p></div><div><br></div><div>Less boilerplate, more focus on the properties which need to be generated.</div><div><br></div><div>Thoughts?</div></div>