<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=""><div class="">A similar thing has been already mentioned in the list.&nbsp;</div><div class="">I can remember the topic "<span style="font-family: 'Helvetica Neue';" class="">[swift-evolution] protocol based invocation forwarding" which could resolve in a similar feature.</span></div><div class=""><span style="font-family: 'Helvetica Neue';" class="">As I said in there I would be really interested to see this in the language as will allow us to be more type safe with types that are commonly described as strings or numbers, but that are more than that.&nbsp;</span></div><div class=""><span style="font-family: 'Helvetica Neue';" class="">Cheers,</span></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">El 11 dic 2015, a las 20:30, Gwendal Roué via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; escribió:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Considering the number of times I’ve read about this topic in other languages, I must agree :-)</div><div class=""><br class=""></div><div class="">Yet there are two difficulties:</div><div class=""><br class=""></div><div class="">First, what does Bar get from Double ?</div><div class=""><br class=""></div><div class="">When you say "after creating Bar, I can extend Bar independenly of Double", the problem lies in the meaning of "after". In a language like Ruby, there is an "after", but there is no such clear thing in Swift: modules/packages are compiled as a whole, and module A can extend a type defined the the module B.</div><div class=""><br class=""></div><div class="">More, let’s see what happens below:</div><div class=""><br class=""></div><div class=""><div class="">1<span class="Apple-tab-span" style="white-space:pre">        </span>let d: Double = 1.0</div><div class="">2<span class="Apple-tab-span" style="white-space:pre">        </span>let b: Bar = d<span class="Apple-tab-span" style="white-space:pre">                        </span>// Compiler error, I presume.</div><div class="">3<span class="Apple-tab-span" style="white-space: pre;">        </span>let b: Bar&nbsp;= Bar(d)<span class="Apple-tab-span" style="white-space: pre;">                </span>// Mandatory so that Bar can be put to any use</div><div class="">4<span class="Apple-tab-span" style="white-space:pre">        </span>let b: Bar&nbsp;= 1.0</div></div><div class=""><br class=""></div><div class="">That point 4 is tricky.</div><div class=""><br class=""></div><div class="">If it is not an error, then 2. should succeed as well, don’t you think?</div><div class="">If it is an error, then one may want to add FloatLiteralConvertible to Bar. Oops, Double already implements it.</div><div class=""><br class=""></div><div class="">Hm. I’m afraid I haven’t found the solution :-)</div><div class=""><br class=""></div><div class="">Gwendal Roué</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 11 déc. 2015 à 21:09, Tuur Anton via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" class="">
  
  <div class="">
<div class="">//Existing typealias feature.</div><div class="">//Foo acts exactly the same way as Double. It's the same thing.</div><div class="">//Double can be used instead of Foo anywhere.</div><div class="">typealias Foo = Double</div><div class=""><br class=""></div><div class="">//Proposed newtype feature.</div><div class="">//Bar acts exactly the same way as Double and &nbsp;is the same</div><div class="">//thing behind the scenes (until we extend it; see below).</div><div class="">//Trying to use Double instead of Bar will result in a compile-time error.</div><div class="">newtype Bar = Double</div><div class=""><br class=""></div><div class="">Of course, after creating Bar - a "copy" of the type Double, so to speak - I can extend Bar independenly of Double as one would expect.</div><div class=""><br class=""></div><div class="">This would be highly useful.</div><div class=""><br class=""></div><div class="">Your thoughts?</div>  
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=GUvuDT95GpxW2sIYHiKg6obX3uIIobaj9awaKuut6Z9P7J-2BsgVSwUjTRK8BQPXpkw8-2BYJdWc0UKVCONS0aE3CbmSncSTVMv33HWIisrxG-2B6V1EOH-2F-2F3zIK-2FXibpWL1OW5DyO-2FXmZU4doUrhlmSsKgMhEn88GsxJLFd2XD-2FCaTim-2FbhDlXmBXrYhQwRm-2BHWqkfdZpjEl5a4U53m63EANkRhKPLorf-2BBQwxvq24nssOT8-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>


_______________________________________________<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=""></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ugfoipfLFYQJoLOuZfhEMRzWwNIL3Gkut5GUvNxqU0fQT8AGPyKP4suEJbxTHW0q24NUFJRWagtDVoUP7G7OVuuBeG-2FJjSlz1mR3-2FykWJKQba3y-2F88eYkGh7sVAdFRya7ENFf-2FU7Z7QkvRzpxHhqhpFPDZwJPK8RqY8sTV3aE1-2BhUqKRzl9GBWGsraoxxISGI6dsujwGVUOLFQQvAdPTgWYt-2B-2FSmFVq1XskgN1oP9Ck-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>