<div dir="ltr"><div>&gt; <span style="font-size:12.8px">Huh? You just said that one usage scenario was the allocation of buffers of known size. If you&#39;re unsatisfied with the API for that, you&#39;re welcome to propose better ones. The point is that this is not a convincing use case, as you claim, for `DefaultConstructible`, but rather for better buffer APIs.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I&#39;ve brought up several situation where I&#39;d use these. I don&#39;t want a better buffer API, I want a way of expressing myself in a way that seems natural to me.</span></div><div><br></div>&gt; <span style="font-size:12.8px">There is no nexus between comparability and &quot;some sort of origin or zero&quot; from which to measure absolute distance, as you state.</span><div><br></div><div><span style="font-size:12.8px">There is. Elements are equal if the distance between them is zero. Why does Comparability also require Equatability?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">Ooh boy. There is no worldview in music that &quot;doesn&#39;t say anything about intervals,&quot; I can assure you of that.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><a href="https://github.com/midiguchi/midiguchi" target="_blank">https://github.com/midiguchi/<wbr>midiguchi</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Do you see the zip operation? Could you tell me what it does? Note that I have no relationship to this project. I can find more if I really try. So now there is a precedence, so what&#39;s next? Are you going to tell me that this doesn&#39;t count? Why not?  I was aware of this library even before this discussion btw.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">No, I mean that you are incorrect.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Well if you say so it must be true. Lol. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">What closure property? My question was, why are you not using `Strideable`? You are describing its semantics. I&#39;m not sure what closure you are referring to.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Algebraic closure.</span></div><div><span style="font-size:12.8px"><br></span></div><div>&gt; <span style="font-size:12.8px">As I explained earlier, your argument _is_ circular. But it&#39;s clear now you will not accept that being point out to you by multiple people independently.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">It&#39;s not circular, it&#39;s I use data point to point out that this is a common pattern.</span></div><div><br></div><div><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 1:43 PM, Xiaodi Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">On Mon, Dec 26, 2016 at 4:28 PM, Adam Nemecek <span dir="ltr">&lt;<a href="mailto:adamnemecek@gmail.com" target="_blank">adamnemecek@gmail.com</a>&gt;</span> wrote:<br><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"><span><div>&gt; <span style="font-size:12.8px">`ManagedBuffer` is the standard library base class that offers facilities for managing buffers. If there&#39;s a concrete use case that isn&#39;t served, then the argument would be to improve `ManagedBuffer` or to design other types or protocols for that use case, not to add a protocol to conform every type that implements `init()`.</span></div><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">I&#39;d prefer not to deal with raw storage unless necessary. </span></div></div></blockquote><div><br></div><div>Huh? You just said that one usage scenario was the allocation of buffers of known size. If you&#39;re unsatisfied with the API for that, you&#39;re welcome to propose better ones. The point is that this is not a convincing use case, as you claim, for `DefaultConstructible`, but rather for better buffer APIs.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>&gt; <span style="font-size:12.8px">The distance between two values of type T does not itself need to be of type T,</span><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">Never said otherwise.</span></div><span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">Moreover, one can have distances being strideable opaque types that can&#39;t even be initialized</span><span style="font-size:12.8px"> </span></div><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">You sure can. Doesn&#39;t disprove any of my points.</span></div></div></blockquote><div><br></div><div>Sure it does. You asserted that where a type is comparable, it &quot;generally&quot; makes sense to measure distance from &quot;some sort of origin or zero.&quot; And I&#39;m showing you why it does not generally make sense at all. There is no nexus between comparability and &quot;some sort of origin or zero&quot; from which to measure absolute distance, as you state.</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"><span><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">This example does not make sense, computationally or musically.</span><span style="font-size:12.8px"> </span></div><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">You mean that it does not make any sense to you.</span></div></div></blockquote><div><br></div><div>No, I mean that you are incorrect.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px">I have two midi streams (and they are midi) and I want to use one midi note to transpose the other.</span></div></div></blockquote><div><br></div><div>There is no such concept in music theory as &quot;using one note to transpose the other.&quot; Sorry.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px">I&#39;m pretty sure that I can find a machine that does this in hardware if I really try. Does the fact that such machine might exist imbue the concept of midi addition with any meaning? </span></div><span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">You are describing a `Strideable` type. That is already in the stdlib. If you want to use `+` to denote `advanced(by:)`, that&#39;s easy to add by extension. I&#39;m not sure why you decided to reinvent it and call it `Addable`.</span></div><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">I don&#39;t always need the closure property. </span></div></div></blockquote><div><br></div><div>What closure property? My question was, why are you not using `Strideable`? You are describing its semantics. I&#39;m not sure what closure you are referring to.</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"><span><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">Doubling the frequency shifts the pitch of a note by an octave; tripling the frequency gets you an octave + a perfect fifth. If you work through the mathematics behind this, you&#39;ll understand the issues behind equal temperament and well temperament.</span></div><div><br></div></span><div>You are not multiplying pitch by pitch but pitch by number. Pitch + Pitch makes complete sense if you accept the midi worldview which doesn&#39;t say anything about intervals</div></div></blockquote><div><br></div><div>Ooh boy. There is no worldview in music that &quot;doesn&#39;t say anything about intervals,&quot; I can assure you of that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>and you realize that the computational distinction between the two is tenuous at best. But this discussion is neither here, nor there. </div></div><div class="m_-4507405587073185514m_4937724216879982240HOEnZb"><div class="m_-4507405587073185514m_4937724216879982240h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 1:09 PM, Xiaodi Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>On Mon, Dec 26, 2016 at 1:50 PM, Adam Nemecek via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-">&gt; <span style="font-size:12.8px">Equatable is *very* different.  It has a whole page of semantics. </span><div><span style="font-size:12.8px"><br></span></div></span><div><span style="font-size:12.8px">DefaultConstructible comes in handy when you want to write an algorithm that works with a constant sized buffer and you need to initialize the buffer to some default values that will be replaced once you have actual data. Or some objects can initialize themselves from static data (e.g. each object has a sequential id and uses a counter that it increments in init). But in all cases, you want to make sure that the array is statically sized.</span></div></div></blockquote><div><br></div></span><div>`ManagedBuffer` is the standard library base class that offers facilities for managing buffers. If there&#39;s a concrete use case that isn&#39;t served, then the argument would be to improve `ManagedBuffer` or to design other types or protocols for that use case, not to add a protocol to conform every type that implements `init()`.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px">For me, it also has some implicit meaning of a zero which I agree might be a stretch in general but this is more explicit in cases where types are comparable. Order theory requires a bottom or zero for a reason. Fundamentally, if two elements are comparable, it makes sense to ask what is the distance between them. And the magnitude of these elements is generally measured as a distance from some sort of origin or zero. </span></div></div></blockquote><div><br></div></span><div>Careful, total ordering does not require a notion of an origin; not at all. The distance between two values of type T does not itself need to be of type T, and there need be no value of type T that represents any sort of &quot;zero.&quot; Moreover, one can have distances being strideable opaque types that can&#39;t even be initialized (i.e. distances can be of a type U such that two values can have a relative distance between them, but `U.init()` isn&#39;t public).</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">Protocols (a.k.a. concepts) are not just bags of syntax; unless you can</span><br></div><span style="font-size:12.8px">attach semantics to the operations,  </span><span style="font-size:12.8px">you can&#39;t write useful generic </span><span style="font-size:12.8px">algorithms against them.  So we shouldn&#39;t have DefaultConstructible for</span></div><div><span style="font-size:12.8px">the same reason we shouldn&#39;t have “Plusable” to represent something that</span><br style="font-size:12.8px"><span style="font-size:12.8px">lets you write x + x.</span><br style="font-size:12.8px"><div style="font-size:12.8px"><div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712gmail-m_7134921280786854437gmail-adm"><div id="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712gmail-m_7134921280786854437gmail-q_15939685645a0044_2" class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712gmail-m_7134921280786854437gmail-ajR m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712gmail-m_7134921280786854437gmail-h4"></div></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Haha, I totally have an Addable protocol. Out of curiosity why is it bad? My use case is for example a struct that&#39;s fundamentally a wrapper around some numerical value (int) and not all numerical operations make sense but e.g. addition makes total sense. E.g. a midi note event where addition gives you a transposition but multiplication doesn&#39;t make sense.</span></div></div></div></blockquote><div><br></div></span><div>This example does not make sense, computationally or musically. Firstly, transposition is the shifting of pitch by an _interval_; if `Self` is a MIDI note (as you imply below), transposition cannot be by addition of type `Self` but rather of `Self.Stride`. Secondly, you can absolutely multiply a note by an integer factor. Doubling the frequency shifts the pitch of a note by an octave; tripling the frequency gets you an octave + a perfect fifth. If you work through the mathematics behind this, you&#39;ll understand the issues behind equal temperament and well temperament.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><span style="font-size:12.8px">In this case the default value (zero) is the value that results in no transposition. And if I extend this, what if I have two equally sized arrays of midi events where one represents a transposition and the other represents the notes I&#39;m transposing and I want to combine them to produce the transposed notes, I can write this algorithm as </span></div><div><span style="font-size:12.8px"><br></span></div><div>







<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1">extension Collection where Iterator.Element: Addable {</p>
<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span>        func transpose(_ other: Self) -&gt; [Iterator.Element] {</p><p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"></p>
<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span>            assert(count == other.count)</p><p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"></p>
<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span>            return zip(self, other).map { $0 + $1 }</p><p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"></p>
<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1"><span class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-Apple-tab-span"></span>    }</p>
<p class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-p1">}</p></div><div><span style="font-size:12.8px">I&#39;m not sure if this example is too concrete and specific to my needs but I&#39;ve been trying to use Swift as a language for making these little algebras with a pretty good degree of success but some things like this would be pretty helpful I think. </span></div></div></div></blockquote><div><br></div></span><div>You are describing a `Strideable` type. That is already in the stdlib. If you want to use `+` to denote `advanced(by:)`, that&#39;s easy to add by extension. I&#39;m not sure why you decided to reinvent it and call it `Addable`.</div><div><div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537h5"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-h5"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 26, 2016 at 9:29 AM, Dave Abrahams via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span><br>
on Mon Dec 26 2016, Jonathan Hull &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt; Just because something is simple, doesn’t mean it isn’t important.  You can do a lot with ‘return<br>
&gt; T()’ that you can’t do without it (namely make a T).<br>
<br>
</span>Sure, but the question remains: *should* you make a T in those<br>
circumstances?  Maybe you<br>
<br>
With DefaultConstructible, you don&#39;t know anything about the value of<br>
this T.  There is nothing you can do with it, reliably.  If the default<br>
constructability requirement is part of some larger protocol like<br>
RangeReplaceableCollection, then you can say things like, “this makes an<br>
empty collection,” and “a default-constructed instance is equivalent to an<br>
instance on which you&#39;ve called removeAll.”  That doesn&#39;t argue for<br>
factoring the init() out into its own protocol.  It argues for including<br>
the init() requirement in every protocol where it forms an important<br>
part of the protocol&#39;s semantic basis operations.<br>
<span><br>
&gt; Equatable is similar.  Semantically, it just lets you ask if two instances of the same type are<br>
&gt; equal.<br>
<br>
</span>Equatable is *very* different.  It has a whole page of semantics.  Read<br>
from “Equality implies substitutability” to the end of the page at<br>
<a href="http://swiftdoc.org/v3.0/protocol/Equatable/" rel="noreferrer" target="_blank">http://swiftdoc.org/v3.0/proto<wbr>col/Equatable/</a>.<br>
<span><br>
&gt; The fact that it only does one thing doesn’t mean it isn’t useful or<br>
&gt; necessary as a small part of a lot of different algorithms.<br>
&gt;<br>
&gt; I find I use T() most often in factory or builder patterns, but any creational pattern may need it.<br>
&gt; It is also often used together with other protocols.  The code is all pretty boring…<br>
&gt;<br>
&gt;       func hasOptionalParam( a: T = T() ) {} //The caller can pass in<br>
&gt; a specific thing, or just leave out the parameter to use a vanilla one<br>
&gt; or<br>
&gt;<br>
&gt;       var t = T()<br>
&gt;       t.somethingFancy() //Provided by unrelated protocol<br>
&gt;       t.moreFancy()<br>
&gt;       return t<br>
&gt;<br>
&gt; or<br>
&gt;<br>
&gt;       var t = T()<br>
&gt;       if t is SomeOtherProtocol {<br>
&gt;               //Do something fancy<br>
&gt;       }<br>
&gt;       if t is YetAnotherProtocol {<br>
&gt;               //Do something else fancy<br>
&gt;       }<br>
&gt;       return t<br>
&gt;<br>
&gt; All of the “fancy stuff” will be done by conforming to other protocols, but those protocols may have<br>
&gt; nothing to do with creation (nor should they).  There is nothing wrong with requiring conformance to<br>
&gt; multiple protocols...<br>
<br>
</span>No, there isn&#39;t.  There *is* something wrong with slicing meaningful<br>
protocols up into bits that have only syntactic value, though.  I<br>
suspect that&#39;s what&#39;s going on here.<br>
<span><br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Jon<br>
&gt;<br>
&gt;&gt; On Dec 26, 2016, at 7:10 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; The question still remains unanswered, what generic algorithms are<br>
&gt;&gt; enabled by having such a protocol? After a long chain, the answer so<br>
&gt;&gt; far is `return T()`. Indeed, afaict, the semantics you are proposing<br>
&gt;&gt; would explicitly limit us to that.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Dec 26, 2016 at 09:32 Jonathan Hull<br>
</span><span>&gt;&gt; &lt;<a href="mailto:jhull@gbis.com" target="_blank">jhull@gbis.com</a> &lt;mailto:<a href="mailto:jhull@gbis.com" target="_blank">jhull@gbis.com</a>&gt;&gt; wrote:<br>
&gt;&gt; My two cents:<br>
&gt;&gt; 1) T() should NOT have anything to do with zero or even<br>
&gt;&gt; “default&quot;. (If we need semantic zero, create a protocol with a .zero<br>
&gt;&gt; static func/var)<br>
&gt;&gt; 2) This comes up enough in my programming, and is such a fundamental<br>
&gt;&gt; concept, that T() probably DOES deserve special treatment in the<br>
&gt;&gt; form of a protocol<br>
&gt;&gt; 3) The semantics of that protocol would be “Things which can be<br>
&gt;&gt; created without any additional information beyond their Type”<br>
&gt;&gt; 4) We should keep working on the name<br>
&gt;&gt;<br>
&gt;&gt; As to whether the protocol needs to be implicit… I am unsure.  It<br>
&gt;&gt; may be enough to have the standard library + cocoa types conform<br>
&gt;&gt; where appropriate.  On the other hand, I can’t think of any type<br>
&gt;&gt; having T() which would not fit the above semantics… and I would<br>
&gt;&gt; guess around 85~90% of types have it, so it may be worth the trouble<br>
&gt;&gt; to make it implicit in this specific case.  I am on the fence, but<br>
&gt;&gt; would probably lean against making it implicit.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Jon<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; On Dec 25, 2016, at 11:28 PM, Daniel Leping via swift-evolution<br>
&gt;&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.<wbr>org</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It&#39;s not a matter of probability, but rather of certainty. Please.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 12:56 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 2:19 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; I totally agree Swift is an opinionated language and it&#39;s good.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Also I have been thinking of DefaultConstructable vs reflection for<br>
&gt;&gt;&gt; generic factories and I would prefer to stick to the protocol as it<br>
&gt;&gt;&gt; gives compile time type safety check. With reflection the only way<br>
&gt;&gt;&gt; is to through an exception if there is no init. So again +1 pro to<br>
&gt;&gt;&gt; DefaultConstructable.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Well, you can&#39;t argue both ways. Either so many types implement<br>
&gt;&gt;&gt; `init()` that it is unusually onerous to type, in which case you<br>
&gt;&gt;&gt; will gain nearly nothing from compile-time checks, or not so many<br>
&gt;&gt;&gt; types implement `init()`, and you can conform those types to a<br>
&gt;&gt;&gt; protocol by yourself :)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 12:32 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 1:48 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<div><div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712h5">&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; Well, AnyObject exists on Linux with no bridging. Still it&#39;s IMPLICITELY conformed by all classes.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; What you say is just another approach to the same issue and we can<br>
&gt;&gt;&gt; argue for eternity. However, I am very positive with syntactic<br>
&gt;&gt;&gt; sugar and this one falls exactly to sugar category. Make people<br>
&gt;&gt;&gt; lifes easier ;)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Moreover it will never ever do any harm.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Adding an easy way to get another set of frameworks/approaches/etc<br>
&gt;&gt;&gt; (proven by time, btw) on board sounds very appealing to me. I wish<br>
&gt;&gt;&gt; to see Swift a very diverse ecosystem and this Pitch serves exactly<br>
&gt;&gt;&gt; this goal.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Yes, we should let others chime in on this issue. I will just end<br>
&gt;&gt;&gt; by saying that I&#39;ve always appreciated how the core team has been<br>
&gt;&gt;&gt; very careful and thoughtful about certain precepts, and how they&#39;ve<br>
&gt;&gt;&gt; stuck to the idea that Swift is an _opinionated_ language.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In particular, I appreciate that there&#39;s a huge amount of thought<br>
&gt;&gt;&gt; put into semantic meaning. The notion that protocols should carry<br>
&gt;&gt;&gt; semantics has been adhered to very strictly. This is why I think<br>
&gt;&gt;&gt; this proposal does do harm, because it explicitly rejects that very<br>
&gt;&gt;&gt; important idea, one that can only be upheld by people and not<br>
&gt;&gt;&gt; compilers.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (Another semantic distinction observed in Swift is that a boolean<br>
&gt;&gt;&gt; value has semantic meaning and is not just a bit; this is why, for<br>
&gt;&gt;&gt; instance, the FloatingPoint protocols define an `enum<br>
&gt;&gt;&gt; FloatingPointSign { case plus, minus }`--because floating point<br>
&gt;&gt;&gt; sign has different _semantics_ from a Bool.)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Let&#39;s just see if it gets any more positive votes.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 12:10 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</div></div><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 1:21 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; I believe you&#39;re confusing in-class factory methods with factory pattern.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Factories can be separate objects and it&#39;s a very different situation.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Fair, but I understand both to fall under the umbrella of &quot;any<br>
&gt;&gt;&gt; factory pattern&quot; and just wanted to point out that at least some of<br>
&gt;&gt;&gt; those patterns seem to be discouraged :)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In any case, I think it&#39;s fair to say that the question &quot;does this<br>
&gt;&gt;&gt; type implement `init()`?&quot; is properly a reflection question and not<br>
&gt;&gt;&gt; a protocol conformance question: the answer provides no semantic<br>
&gt;&gt;&gt; guarantees whatsoever about the value that you get from `init()`,<br>
&gt;&gt;&gt; and in your use case you do not care and simply want to invoke the<br>
&gt;&gt;&gt; initializer and return what you get from it. Now, in a perfect<br>
&gt;&gt;&gt; world where the reflection facilities that Swift provided were<br>
&gt;&gt;&gt; essentially free of performance cost, would you object to that<br>
&gt;&gt;&gt; characterization?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You&#39;re certainly right that `AnyObject` has magic. It&#39;s rather<br>
&gt;&gt;&gt; obvious that Obj-C bridging is non-negotiable for Swift, and of<br>
&gt;&gt;&gt; course a bridged type is all sorts of different under the hood from<br>
&gt;&gt;&gt; a native type. I&#39;m going to take a wild guess that no other use<br>
&gt;&gt;&gt; case would pass that high bar for magic.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 11:46 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 1:10 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; I&#39;m giving a wider range, which is about ANY factory pattern<br>
&gt;&gt;&gt; related stuff. Doesn&#39;t look to be narrow to me.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I thought factory methods were regarded as undesirable in Swift?<br>
&gt;&gt;&gt; One of the stated reasons for failable initializers was: &quot;Failable<br>
&gt;&gt;&gt; initializers eliminate the most common reason for factory methods<br>
&gt;&gt;&gt; in Swift... Using the failable initializer allows greater use of<br>
&gt;&gt;&gt; Swift’s uniform construction syntax, which simplifies the language<br>
&gt;&gt;&gt; by eliminating the confusion and duplication between initializers<br>
&gt;&gt;&gt; and factory methods.&quot;<br>
&gt;&gt;&gt; &lt;<a href="https://developer.apple.com/swift/blog/?id=17" rel="noreferrer" target="_blank">https://developer.apple.com/s<wbr>wift/blog/?id=17</a><br>
&gt;&gt;&gt; &lt;<a href="https://developer.apple.com/swift/blog/?id=17" rel="noreferrer" target="_blank">https://developer.apple.com/s<wbr>wift/blog/?id=17</a>&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 11:38 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 12:58 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; Well, reflection is a huge performance drop. Protocol conformance is way better.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m not sure how huge it would be in the grand scheme of things; in<br>
&gt;&gt;&gt; your example, you are still evaluating a train of protocol<br>
&gt;&gt;&gt; conformances and casting at runtime. Of course, compiler magic can<br>
&gt;&gt;&gt; be fast, but I still don&#39;t see how this is a &quot;very common use case&quot;<br>
&gt;&gt;&gt; (as you write) that would justify magic equivalent to that for<br>
&gt;&gt;&gt; Objective-C bridging, which is what you&#39;re saying it should be. If<br>
&gt;&gt;&gt; `DefaultConstructible` is useful only when it&#39;s magic and the<br>
&gt;&gt;&gt; specific use case is dependency injection/inversion of control,<br>
&gt;&gt;&gt; then we&#39;re getting very specialized here.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 11:26 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 12:50 AM, Daniel Leping<br>
&gt;&gt;&gt; &lt;<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.xyz</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:daniel@crossroadlabs.xyz" target="_blank">daniel@crossroadlabs.x<wbr>yz</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; I&#39;m not arguing for implicit conformance in general, but I&#39;m<br>
&gt;&gt;&gt; telling that DefaultConstructable is the same basic level as<br>
&gt;&gt;&gt; AnyObject, which is conformed implicitly.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Shortly, I&#39;m against implicit conformance in general. I&#39;m positive<br>
&gt;&gt;&gt; with &quot;automatic compiler magic&quot; conformance to DefaultConstructable<br>
&gt;&gt;&gt; for any object having a default constructor as it really is a very<br>
&gt;&gt;&gt; basic stuff. Otherwise you will have to add explicit conformance to<br>
&gt;&gt;&gt; it in almost every class of yours (annoying).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Well, this sounds very different from Adam&#39;s proposal, where he<br>
&gt;&gt;&gt; proposes semantic meaning for `init()` that, as he described, means<br>
&gt;&gt;&gt; that it cannot apply to every type that implements<br>
&gt;&gt;&gt; `init()`. However, he also just said that he thinks that all types<br>
&gt;&gt;&gt; with `init()` should conform, so I guess I&#39;m confused which way<br>
&gt;&gt;&gt; that is.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; At base, you want a way of knowing if a type has `init()`. That<br>
&gt;&gt;&gt; sounds like reflection to me, not protocol conformance. For the<br>
&gt;&gt;&gt; record, I look forward to the day when AnyObject magic is removed;<br>
&gt;&gt;&gt; I assume it is coming eventually.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, 26 Dec 2016 at 11:14 Xiaodi Wu<br>
&gt;&gt;&gt; &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a><br>
</span><span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt; On Mon, Dec 26, 2016 at 12:43 AM, Daniel Leping via swift-evolution<br>
&gt;&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.<wbr>org</a>&gt;&gt;<br>
<span>&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt; Thank you, Adam!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Wait, are you arguing for implicit conformance or not?<br>
&gt;&gt;&gt;<br>
</span><span>&gt;&gt;&gt; On Mon, 26 Dec 2016 at 11:12 Adam Nemecek via swift-evolution<br>
&gt;&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
</span>&gt;&gt;&gt; &lt;mailto:<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.<wbr>org</a>&gt;&gt;<br>
<div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712HOEnZb"><div class="m_-4507405587073185514m_4937724216879982240m_-1279035214527698537m_1036267489738941891gmail-m_4919129153461230770gmail-m_-2797573570486692712h5"><span>&gt;&gt;&gt; wrote:<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
&gt;<br>
<br></span><span class="m_-4507405587073185514HOEnZb"><font color="#888888">
--<br>
-Dave</font></span><span><br>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
</span></div></div></blockquote></div><br></div></div></div></div><span>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></span></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>
</blockquote></div><br></div></div>