<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="">By the way, this doesn’t mean it can’t be done, or that we can’t decide on some kind of partial solution! It just means that it needs to be carefully considered and explicitly addressed.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2016, at 15:49, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:</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="">We thought about that too. The problem is that it’s not always obvious what NSString or NSAttributedString the indexes refer to. For example, most of the NSRegularExpression APIs produce matches in the form of NSTextCheckingResult, which then doesn’t have a reference to the original string.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 10, 2016, at 13:43, Zach Waldowski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">


<title class=""></title>

<div class=""><div style="font-family:Arial;" class="">Would it be feasible to annotate those and have them appropriately converted to Range&lt;String.UTF16Index&gt; upon crossing the bridge? Thinking in particular of TextKit and friends — it'd away with quite a lot of the pain of, e.g., not having a native struct-y AttributedString.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div id="sig40804545" class=""><div class="signature">Cheers!<br class=""></div>
<div class="signature">&nbsp; Zachary Waldowski<br class=""></div>
<div class="signature">&nbsp;&nbsp;<a href="mailto:zach@waldowski.me" class="">zach@waldowski.me</a><br class=""></div>
</div>
<div class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div class="">On Tue, May 10, 2016, at 12:37 PM, Jordan Rose via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">One particular concern we've had is that many NSRanges aren’t Range&lt;Int&gt;; they’re Range&lt;String.UTF16Index&gt;. I suppose things wouldn’t get any <i class="">worse</i>&nbsp;there, though.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Jordan<br class=""></div>
<div class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On May 10, 2016, at 00:14, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div class=""><div class=""><div style="font-family:Arial;" class="">But it’s reasonably implementable? I guess the answer is yes if you have already faced the same bridging concerns with NSArray/Array. I’de really like this going forward, but I don’t know how confident I am in writing a proposal.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class=""><div style="font-family:Arial;" class="">On 10 May 2016, at 08:29, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class=""><div style="font-family:Arial;" class="">On May 9, 2016, at 11:23 PM, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">Why wouldn't it completely eliminate NSRange?<br class=""></div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">Because NSRange has a different representation than Range&lt;Int&gt; (start+length vs. start/end), a pointer-to-NSRange has to come in as Unsafe(Mutable)Pointer&lt;NSRange&gt; rather than Unsafe(Mutable)Pointer&lt;Range&lt;Int&gt;&gt;. It’s the same reason that (e.g.), an NSArray** parameter comes in as UnsafeMutablePointer&lt;NSArray&gt; rather than UnsafeMutablePointer&lt;[AnyObject]&gt;.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class="">Are you thinking of NSNotFound? Could we migrate those APIs to return an Optional Range&lt;Int&gt;?<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">If you had annotations on the APIs to say that they use NSNotFound as a sentinel, yes.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span style="white-space:pre;" class=""> </span>- Doug<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class=""><div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class=""><div style="font-family:Arial;" class="">On 10 May 2016, at 05:49, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote type="cite" class=""><div style="font-family:Arial;" class="">On May 8, 2016, at 2:10 PM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">Hello Swift-Evolution,<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">I spent some time coding on Linux with Swift 3 (latest developement snapshot) and corelibs-foundation and I’ve hit one major hurdle: passing and converting NSRange and Range around between the different stdlib and Foundation APIs - specifically in regards to String.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">Is there a plan to simplify those pain points by converting all corelibs-foundation APIs to accept/return Range on String instead of NSRange? In that case, can’t we get rid of NSRange completely?<br class=""></div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">One idea that had come up before was to bridge NSRange to Range&lt;Int&gt;, although it wouldn’t completely eliminate NSRange because the two types are not representationally identical.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""> - Doug<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">_______________________________________________<br class=""></div>
<div style="font-family:Arial;" class="">swift-evolution mailing list<br class=""></div>
<div style="font-family:Arial;" class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div style="font-family:Arial;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</div>
</blockquote></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div 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 style="font-family:Arial;" class="">&nbsp;</div>
</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=""></div></div></blockquote></div><br class=""></body></html>