Thought: if the idea is performance and not drop-in replacement, why force the user to incur two copies? If the initial value were inout, this function would be more unambiguous even without a new name, and at _worst_ the user has to declare a variable with var, a worthwhile trade-off to save two copies.<br><br>(Ack, Jeremy just beat me to it!)<br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 18, 2017 at 05:45 Chris Eidhof via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<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">I opened up a WIP PR on the SE repository (so many TLA&#39;s!). <a href="https://github.com/apple/swift-evolution/pull/587" class="gmail_msg" target="_blank">https://github.com/apple/swift-evolution/pull/587</a><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think I&#39;ll wait a few days before removing `WIP` until the naming discussion either reaches consensus or settles down.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">So far, I would summarize the thread as: people are in favor, but there is disagreement on the naming. I suspect the core team will ultimately decide on the naming?</div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Wed, Jan 18, 2017 at 11:11 AM, Chris Eidhof <span dir="ltr" class="gmail_msg">&lt;<a href="mailto:chris@eidhof.nl" class="gmail_msg" target="_blank">chris@eidhof.nl</a>&gt;</span> wrote:<br class="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">I don&#39;t think we should replace the current `reduce` with the `inout` version, also because the current reduce can be really useful as well (e.g. when the return type is an Int). <div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">One downside of having a different name is that it&#39;ll be harder to discover this version. If stressing the type-checker is the only problem, then maybe we should improve the type-checker, instead of placing that burden on every user of the language.</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_extra gmail_msg"><div class="gmail_msg"><div class="m_376491311775212594h5 gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Wed, Jan 18, 2017 at 9:36 AM, Karl Wagner 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"><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="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="m_376491311775212594m_-7040241973466185661h5 gmail_msg"><div class="gmail_msg">On 18 Jan 2017, at 09:00, Anton Zhilin via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_376491311775212594m_-7040241973466185661m_-2796232354106425939Apple-interchange-newline gmail_msg"></div></div><div class="gmail_msg"><div class="gmail_msg"><div class="m_376491311775212594m_-7040241973466185661h5 gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">While realizing that this name can cause confusion, I&#39;d still prefer `reduce(mutating:_:)`, because it looks like the only readable option to me.</div><div class="gmail_quote gmail_msg">Whatever name will be picked, I agree that traditional reduce without mutation should retain its name.</div><div class="gmail_quote gmail_msg"><br class="gmail_msg"></div><div class="gmail_quote gmail_msg">2017-01-18 5:17 GMT+03:00 Xiaodi Wu 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>:<br class="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">A serious possibility would be: `reduce(mutableCopyOf: x) { ... }`.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It&#39;s verbose, but the nicer-looking `reduce(mutating: x) { ... }` is incorrect since, as Charles pointed out to Dave, it&#39;s not `x` that&#39;s mutated but rather a mutable copy of it, so it doesn&#39;t matter if `x` itself is declared with `let` or `var`. </div></div></blockquote></div></div></div></div></div>
_______________________________________________<span class="gmail_msg"><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" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></span></div></blockquote></div><br class="gmail_msg"><div class="gmail_msg">I suppose as a second-choice I’d go for accumulate(into: with:):</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">[1, 2, 3].accumulate(into: 0, with: +=) </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">even [1, 2, 3].accumulate(into: 0, with: -=) doesn’t look so bad IMO.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Karl</div></div><br class="gmail_msg">_______________________________________________<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><br class="gmail_msg"><br clear="all" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div></div><span class="m_376491311775212594HOEnZb gmail_msg"><font color="#888888" class="gmail_msg">-- <br class="gmail_msg"><div class="m_376491311775212594m_-7040241973466185661gmail_signature gmail_msg" data-smartmail="gmail_signature">Chris Eidhof</div>
</font></span></div>
</blockquote></div><br class="gmail_msg"><br clear="all" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div>-- <br class="gmail_msg"><div class="m_376491311775212594gmail_signature gmail_msg" data-smartmail="gmail_signature">Chris Eidhof</div>
</div>
_______________________________________________<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">
</blockquote></div>