<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 <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> 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"> (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><<a href="mailto:andriesseniels@gmail.com" target="_blank">andriesseniels@gmail.com</a>></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"> to </font><font face="monospace, monospace">LosslessStringConvertible</font><font face="arial, helvetica, sans-serif"> like this would mean assuming a radix of 10 in the implementation. That said, this would be consistent with the way </font><font face="monospace, monospace">Int</font><font face="arial, helvetica, sans-serif"> implements </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><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></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><div><br></div><div>On Jul 23, 2017, at 09:15, Matheus Martins via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div><div>I came across what i think is an inconsistency in the standard library.</div><div><br></div><div>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?</div><div><br></div><div>I came across this while trying to write some generic code:</div><div><br></div><div><div>func array<T: LosslessStringConvertible>(_ text: String) -> [T?] {</div><div><span class="m_-4400418474714830553m_-412286965437656225m_5510885133438737253m_549651671855291146gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>return text.components(separatedBy: " ").map { T($0) }</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></span><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>