<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">I think this is a bug. Basing on other numeric types, the intended result would be the same for Int.</div>
<div name="messageReplySection"><br />
On 26 Jul 2017, 7:40 AM +0800, Niels Andriesse via swift-evolution &lt;swift-evolution@swift.org&gt;, wrote:<br />
<blockquote type="cite">
<div>I'm +1 on this.</div>
<div><br />
<div class="gmail_quote">
<div>On Mon, 24 Jul 2017 at 15:37 Niels Andriesse via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br /></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>And <font face="monospace, monospace">CustomStringConvertible</font><font face="arial, helvetica, sans-serif">&#160;(to String) is basically the inverse of</font> <font face="monospace, monospace">LosslessStringConvertible</font> <font face="arial, helvetica, sans-serif">(from String).</font></div>
<div class="gmail_extra">
<div class="gmail_quote">On Mon, Jul 24, 2017 at 3:23 PM, Niels Andriesse <span>&lt;<a href="mailto:andriesseniels@gmail.com" target="_blank">andriesseniels@gmail.com</a>&gt;</span> wrote:<br /></div>
</div>
<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>Just want to point out that conforming <font face="monospace, monospace">Int</font><font face="arial, helvetica, sans-serif">&#160;to</font> <font face="monospace, monospace">LosslessStringConvertible</font><font face="arial, helvetica, sans-serif">&#160;like this would mean assuming a radix of 10 in the implementation. That said, this would be consistent with the way&#160;</font><font face="monospace, monospace">Int</font> <font face="arial, helvetica, sans-serif">implements&#160;</font><font face="monospace, monospace">CustomStringConvertible</font><font face="arial, helvetica, sans-serif">, which also uses a radix of 10.</font></div>
<div class="gmail_extra"><br />
<div class="gmail_quote">
<div>
<div class="m_-4400418474714830553m_-412286965437656225h5">On Mon, Jul 24, 2017 at 4:36 AM, David Sweeris via swift-evolution <span>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br /></div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="m_-4400418474714830553m_-412286965437656225h5">
<div dir="auto"><span></span>
<div><span><br /></span></div>
<div><span>On Jul 23, 2017, at 09:15, Matheus Martins via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br />
<br /></span></div>
<blockquote type="cite"><span></span>
<div><span></span>
<div><span></span>
<div><span>I came across what i think is an inconsistency in the standard library.</span></div>
<div><span><br /></span></div>
<div><span>Why are some numeric types like Int not conforming to LosslessStringConvertible by default while Float and Double do conform to it in the standard library?</span></div>
<div><span><br /></span></div>
<div><span>I came across this while trying to write some generic code:</span></div>
<div><span><br /></span></div>
<div><span></span>
<div><span>func array&lt;T: LosslessStringConvertible&gt;(_ text: String) -&gt; [T?] {</span></div>
<div><span><span class="m_-4400418474714830553m_-412286965437656225m_5510885133438737253m_549651671855291146gmail-Apple-tab-span" style="white-space:pre-wrap"></span>return text.components(separatedBy: " ").map { T($0) }</span></div>
<div>}</div>
</div>
<div><br /></div>
<div>It seems rather inconsistent to me that that allows me to do:</div>
<div><br /></div>
<div>let floats: [Float] = array("1.0 2.2 3")</div>
<div><br /></div>
<div>but i can't do:</div>
<div><br /></div>
<div>let ints: [Int] = array("1 2 3 4 5 6")</div>
<div>"<span style="color:rgb(255,255,255);font-family:Inconsolata,Monaco,Menlo,'Ubuntu Mono',Consolas,source-code-pro,monospace;font-size:13px;background-color:rgb(38,74,96)">type 'Int' does not conform to protocol 'LosslessStringConvertible'</span>"</div>
<div><br /></div>
<div>To further my point, Int is used as the sole example in the LosslessStringConvertible docs: <a href="http://swiftdoc.org/v3.0/protocol/LosslessStringConvertible/" target="_blank">http://swiftdoc.org/v3.0/protocol/LosslessStringConvertible/</a></div>
<div>Yet it does not actually conform to it.</div>
<div><br /></div>
<div>This seems way too basic for me to feel comfortable pitching it here, but i searched and couldn't find any discussion on this on any mailing list or website.</div>
</div>
</div>
</blockquote>
<br />
<div>Sounds like it's a bug to me, either in the docs or stdlib, depending on the intended behavior. Although I doubt they would've used Int in the docs if they weren't intending Int to conform to it.</div>
<div><br /></div>
<div>- Dave Sweeris</div>
</div>
<br /></div>
</div>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br />
<br /></blockquote>
</div>
<br /></div>
</blockquote>
</div>
</div>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br /></blockquote>
</div>
</div>
_______________________________________________<br />
swift-evolution mailing list<br />
swift-evolution@swift.org<br />
https://lists.swift.org/mailman/listinfo/swift-evolution<br /></blockquote>
</div>
</body>
</html>