<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 28, 2016, at 2:24 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Wed, Dec 28, 2016 at 5:21 PM, Anton Zhilin <span dir="ltr" class="">&lt;<a href="mailto:antonyzhilin@gmail.com" target="_blank" class="">antonyzhilin@gmail.com</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><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=""><div class="m_5844606051936114984markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important" class="">What about “Rust way”?</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="">protocol Default {
    static var `default`: Self { get }
}

protocol Setupable {
    mutable func setup(with params: Params)
}

func setupArray&lt;T&gt;(type: T.Type, params: Params) -&gt; [T]
    where T: Default &amp; Setupable
{
    return (1...42).map { i in
        var next = T.default
        next.setup(with: params)
        return next
    }
}
</code></pre><p style="margin:0px 0px 1.2em!important" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">default</code> is literally a “default” value. For primitives like <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">Int</code>, <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">Char</code>, <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">Bool</code>, <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">Float</code> etc. it is all zeros. For structs with <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">Default</code> fields, it’s all <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="">default</code>s—unless some special semantics is given to them. For complex types, it’s an “empty” value, the most sane value before any setup or specification.</p></div></div></blockquote><div class=""><br class=""></div><div class="">The objection is not about the spelling. The point here is that such a protocol does not make sufficient semantic guarantees to enable any interesting generic algorithms not possible without it. As I pointed out, Rust explicitly makes no guarantees as to what the default value is and tells you that you must not care; "most sane" does not cut it as a guarantee.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="m_5844606051936114984markdown-here-wrap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;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="">​</div></div></div>
</blockquote></div></div></div></div></blockquote></div><br class=""><div class="">Right. &nbsp;</div><div class=""><br class=""></div><div class="">Anton, perhaps I missed it, but I haven’t seen any concrete rationale for your proposal. &nbsp;Can you give some specific code examples that become simpler with a default constructible protocol? &nbsp;Perhaps you’re getting pushback because there is a better way to solve the problem you’re facing.</div><div class=""><br class=""></div><div class="">-Chris</div></body></html>