<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div style="font-family:Arial;">Would it be feasible to annotate those and have them appropriately converted to Range<String.UTF16Index> 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></div>
<div style="font-family:Arial;"> </div>
<div id="sig40804545"><div class="signature">Cheers!<br></div>
<div class="signature"> Zachary Waldowski<br></div>
<div class="signature"> <a href="mailto:zach@waldowski.me">zach@waldowski.me</a><br></div>
</div>
<div> </div>
<div> </div>
<div>On Tue, May 10, 2016, at 12:37 PM, Jordan Rose via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>One particular concern we've had is that many NSRanges aren’t Range<Int>; they’re Range<String.UTF16Index>. I suppose things wouldn’t get any <i>worse</i> there, though.<br></div>
<div> </div>
<div>Jordan<br></div>
<div> </div>
<div style="font-family:Arial;"> </div>
<div><blockquote type="cite"><div>On May 10, 2016, at 00:14, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div style="font-family:Arial;"> </div>
<div><div><div style="font-family:Arial;">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></div>
<div style="font-family:Arial;"> </div>
<blockquote type="cite"><div style="font-family:Arial;">On 10 May 2016, at 08:29, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;"> </div>
<blockquote type="cite"><div style="font-family:Arial;">On May 9, 2016, at 11:23 PM, David Hart <<a href="mailto:david@hartbit.com">david@hartbit.com</a>> wrote:<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">Why wouldn't it completely eliminate NSRange?<br></div>
</blockquote><div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">Because NSRange has a different representation than Range<Int> (start+length vs. start/end), a pointer-to-NSRange has to come in as Unsafe(Mutable)Pointer<NSRange> rather than Unsafe(Mutable)Pointer<Range<Int>>. It’s the same reason that (e.g.), an NSArray** parameter comes in as UnsafeMutablePointer<NSArray> rather than UnsafeMutablePointer<[AnyObject]>.<br></div>
<div style="font-family:Arial;"> </div>
<blockquote type="cite">Are you thinking of NSNotFound? Could we migrate those APIs to return an Optional Range<Int>?<br></blockquote><div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">If you had annotations on the APIs to say that they use NSNotFound as a sentinel, yes.<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;"><span style="white-space:pre;"> </span>- Doug<br></div>
<div style="font-family:Arial;"> </div>
<blockquote type="cite"><div style="font-family:Arial;"> </div>
<blockquote type="cite"><div style="font-family:Arial;">On 10 May 2016, at 05:49, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;"> </div>
<blockquote type="cite"><div style="font-family:Arial;">On May 8, 2016, at 2:10 PM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">Hello Swift-Evolution,<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">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></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">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></div>
</blockquote><div style="font-family:Arial;"> </div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">One idea that had come up before was to bridge NSRange to Range<Int>, although it wouldn’t completely eliminate NSRange because the two types are not representationally identical.<br></div>
<div style="font-family:Arial;"> </div>
<div style="font-family:Arial;"> - Doug<br></div>
<div style="font-family:Arial;"> </div>
</blockquote><div style="font-family:Arial;"> </div>
</blockquote><div style="font-family:Arial;"> </div>
</blockquote><div style="font-family:Arial;"> </div>
<div style="font-family:Arial;">_______________________________________________<br></div>
<div style="font-family:Arial;">swift-evolution mailing list<br></div>
<div style="font-family:Arial;"><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div style="font-family:Arial;">https://lists.swift.org/mailman/listinfo/swift-evolution<br></div>
</div>
</div>
</blockquote></div>
<div style="font-family:Arial;"> </div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div style="font-family:Arial;"> </div>
</body>
</html>