<div dir="ltr">On Mon, Dec 26, 2016 at 1:46 PM Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">This sounds like what UnsafeMutableRawBufferPointer was designed for, no?</div></blockquote><div><br></div><div>I can understand the desire to write an algorithm like this without going down to unsafe territory, but yes, that&#39;s probably the right approach—especially since the idea of a non-optional but not-yet-initialized value is inherently unsafe.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Dec 26, 2016 at 4:39 PM, Tony Allevato via swift-evolution <span dir="ltr" class="gmail_msg">&lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><span class="gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, Dec 26, 2016 at 1:19 PM David Sweeris &lt;<a href="mailto:davesweeris@mac.com" class="gmail_msg" target="_blank">davesweeris@mac.com</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">On Dec 26, 2016, at 12:10, Tony Allevato &lt;<a href="mailto:tony.allevato@gmail.com" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg" target="_blank">tony.allevato@gmail.com</a>&gt; wrote:<br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><blockquote type="cite" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div dir="ltr" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">On Mon, Dec 26, 2016 at 11:57 AM David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="gmail_quote m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><blockquote class="gmail_quote m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">On Dec 26, 2016, at 11:35, Tony Allevato &lt;<a href="mailto:allevato@google.com" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg" target="_blank">allevato@google.com</a>&gt; wrote:<br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><blockquote type="cite" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Mathematically, identities are associated with (type, operation) pairs, not types alone.<br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">This conversation has put me in the column of &quot;numeric types shouldn&#39;t have default initializers at all&quot;, personally.
</div></blockquote><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div dir="auto" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">I&#39;d agree, except sometimes you need a T, <i class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">any</i> T, for when you want to create a &quot;pre-sized&quot; array for stuffing results into by index:</div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">for i in ... {</div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">    a[i] = ...</div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">}</div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Simply saying &quot;var a =[T](); a.reserveCapacity()&quot; doesn&#39;t cut it because it&#39;ll still crash if you try to store anything in a[i] without somehow putting at least i+1 elements in the array first.</div></div></blockquote><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Array already has init(repeating:count:) that puts the responsibility of choosing the default value at the call site. If someone were writing a generic algorithm around this, then why not just propagate that responsibility out to its call site as well? That way, the algorithm isn&#39;t making any assumptions about what the &quot;default&quot; value is or even if one exists, and it doesn&#39;t impose additional requirements on the element type. For example, the user could get the default from a static factory method, an instance method on another object, or something else entirely.</div></div></div>
</blockquote><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div style="word-wrap:break-word" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Yeah, that&#39;s what I would use… The &quot;filled out&quot; example would be:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;color:rgb(187,44,162);margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">extension</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Array</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> {</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">    </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">public</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> pmap&lt;T: </span><span style="color:rgb(79,129,135);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">DefaultInitable</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">&gt; (transform: (</span><span style="color:rgb(112,61,170);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Element</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">) -&gt; </span><span style="color:rgb(79,129,135);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">) -&gt; [</span><span style="color:rgb(79,129,135);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">] {</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">        </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> result = </span><span style="color:rgb(112,61,170);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Array</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">&lt;</span><span style="color:rgb(79,129,135);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">&gt;(repeating:</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </span><span style="color:rgb(79,129,135);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">T</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">(), count: </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">self</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">.</span><span style="color:rgb(112,61,170);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">count</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">)</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </span><span style="color:rgb(0,132,0);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">//Pick a T... any T...</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">        </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">for</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> i </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">in</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">self</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">.</span><span style="color:rgb(112,61,170);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">indices</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> {</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">            result[i] =<font color="#bb2ca2" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> </font></span><span style="color:rgb(49,89,93);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">whateverTheConcurrentExectutionSyntaxIs</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">(</span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">self</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">[i</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">], </span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">transform</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">)</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><font color="#bb2ca2" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">        </font>}</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">        </span><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> result</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">    }</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">}</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="color:rgb(187,44,162);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> thisCouldTakeAWhile = </span><span style="color:rgb(112,61,170);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">Array</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">((</span><span style="color:rgb(39,42,216);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">0</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">...</span><span style="color:rgb(39,42,216);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">10000</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">)).</span><span style="color:rgb(49,89,93);font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">pmap</span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"> {</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;color:rgb(49,89,93);margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">    </span><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">someReallySlowFunction</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">($0)</span></div></div></div></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="font-family:Menlo;margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">}</span></div></div></div></div></blockquote><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div style="margin:0px;line-height:normal" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">At least I <i class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">think</i> that’d work... I haven’t tried it yet... Anyway, without some way (<i class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">any</i> way) of getting an instance of T to fill in the `result` array, it becomes much trickier to keep track of all the concurrently-calculated transformed values. In this case, the semantics of `T()` are fairly irrelevant because the semantics of the <i class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">overall statement</i> is just to work around</span> a language limitation (Swift not having separate allocation and initialization phases), which doesn’t have anything to do with the semantics of the initial value that got passed as the `repeating` argument.</div></div></div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></span><div class="gmail_msg">This looks like it&#39;s abusing T() to stand in for nil, though. Before the result[i] assignment executes, result[i] shouldn&#39;t conceptually have a value—you&#39;re putting a default in there because the implementation requires it. T() as a placeholder is just as valid/invalid as any other value in T&#39;s space.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It&#39;s a square-peg-in-a-round-hole problem—design-wise, an array of optionals would be a better fit, but you rightly don&#39;t want to return that from the function, and you don&#39;t want to bear the cost of converting the array of optionals to an array of non-optionals after the computation is complete. That makes complete sense, but perhaps *that* is the problem that should be addressed, instead of trying to use T() to avoid it? Or alternatively, a parallel map operation should return an array of futures (or a collection type that itself is a future).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"><br class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg"></div><div class="m_-6011679638432639202m_-4733316106183183105gmail_msg gmail_msg">- Dave Sweeris</div></div></blockquote></div></div>
<br class="gmail_msg"></blockquote></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div></div></div></div></blockquote></div></div>