<div dir="ltr">I don’t think anyone is really looking at that at the time but +1 to bringing NSString functionality to String. This is something that gets talked about a lot but no one has really sat down to outline what such an API would look like. <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 25, 2017 at 3:24 PM, David Hart via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
&gt; On 25 Oct 2017, at 15:29, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Sent from my iPad<br>
&gt;<br>
&gt;&gt; On Oct 24, 2017, at 5:55 PM, Slava Pestov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I think to maintain source compatibility, the old behavior would be preserved until/if we remove -swift-version 4 mode. By deprecating it though, we won’t have to devote as much time to maintaining it going forward.<br>
&gt;<br>
&gt; I think the point is that some of the APIs should continue to be offered, but directly rather than via NSString.  We need an analysis of what APIs are affected that includes recommendations on which to deprecate and which to replace.  We can’t make an informed decision without that.<br>
<br>
</span>This is also closely linked to the new String APIs which the String Manifesto touched upon but never got implemented. It’d be nice to know what plans the Standard Library team has in that regard for Swift 5.<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;&gt;<br>
&gt;&gt; Slava<br>
&gt;&gt;<br>
&gt;&gt;&gt; On Oct 24, 2017, at 3:54 PM, Philippe Hausler &lt;<a href="mailto:phausler@apple.com">phausler@apple.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I think any serious proposal with the removal of APIs would need to consider source compatibility and to do so you should likely audit the API surface area that is being offered (and replace it via the NSStringAPI.swift extension)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Oct 24, 2017, at 3:12 PM, Slava Pestov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Perhaps you could write up a proposal to outline the missing functionality :-)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Slava<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On Oct 24, 2017, at 3:09 PM, Jonathan Hull &lt;<a href="mailto:jhull@gbis.com">jhull@gbis.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I would feel better about it if String gained a lot of the utility of NSString (so that we don’t have to go to NSString all the time for methods)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt;&gt;&gt; Jon<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; On Oct 24, 2017, at 3:00 PM, Slava Pestov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Members of NSString, except those defined in Foundation, are available on values of type String. For example,<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; extension NSString {<br>
&gt;&gt;&gt;&gt;&gt;&gt; @objc func foo() {}<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; let s: String = “hello”<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; s.foo()<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; We don’t do this for any other bridged types, for instance NSArray methods are not imported as Array methods. It’s literally a special case in the type checker for member lookup on String.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; This behavior doesn’t really much sense conceptually and it was put in as a stop-gap in Swift 1 to beef up the String API. I would like to phase it out as follows:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; - Unconditional warning in Swift 4.1, with a fixit to insert an ‘as NSString’ cast<br>
&gt;&gt;&gt;&gt;&gt;&gt; - Error in Swift 5 with -swift-version 5<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; What does everyone think about this?<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Slava<br>
&gt;&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; swift-evolution mailing list<br>
&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div>