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