<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 29, 2017, at 6:59 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">This looks great. The restored conformances to *Collection will be huge.</div><div class=""><br class=""></div><div class="">Is this to be the first of several or the only major part of the manifesto to be delivered in Swift 4?<br class="gmail_msg"><br class="gmail_msg"></div></div></blockquote><div><br class=""></div><div>First of several. This lays the ground work for the changes to the underlying implementation. Other changes will mostly be additive on top.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Nits on naming: are we calling it Substring or SubString (à la SubSequence)? </div></div></blockquote><div><br class=""></div><div>This is venturing into subjective territory, so these are just my feelings rather than something definitive (Dave may differ) but:</div><div><br class=""></div><div>It should definitely be Substring. My rule of thumb: if you might hyphenate it, you can capitalize it. I don’t think anyone spells it "sub-string". OTOH one <i class="">might</i>&nbsp;write "sub-sequence". Generally hyphens disappear in english as things come into common usage i.e. it used to be e-mail but now it’s mostly just email. &nbsp;Substring is enough of a term of art in programming that this has happened. Admittedly, Subsequence is a term of art too – unfortunately one that has a different meaning to ours ("a&nbsp;sequence&nbsp;that can be derived from another sequence by deleting some elements without changing the order of the remaining elements" e.g. &lt;A,C,E&gt; is a Subsequence of &lt;A,B,C,D,E&gt; – see&nbsp;<a href="https://en.wikipedia.org/wiki/Subsequence" class="">https://en.wikipedia.org/wiki/Subsequence</a>). Even worse, the mathematical term for what we are calling a subsequence is a Substring!</div><div><br class=""></div><div>If we were change anything, my vote would be to lowercase Subsequence. We can typealias SubSequence = Subsequence to aid migration, with a slow burn on deprecating it since it’ll be quite a footling deprecation. I don’t know if it’s worth it though – the main use of “SubSequence” is currently in those pesky where clauses you have to put on all your Collection extensions if you want to use slicing, and many of these will be eliminated once we have the ability to put where clauses on associated types.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">and shouldn't it be UnicodeParsedResult rather than UnicodeParseResult?</div><div class=""><br class=""></div></div></blockquote><div><br class=""></div><div>I think Parse. As in, this is the result of a parse, not these are the parsed results (though it does contain parsed results in some cases, but not all).</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">On Wed, Mar 29, 2017 at 19:32 Ben Cohen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Hi Swift Evolution,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Below is a pitch for the first part of the String revision. This covers a number of changes that would allow the basic internals to be overhauled.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Online version here:&nbsp;<a href="https://github.com/airspeedswift/swift-evolution/blob/3a822c799011ace682712532cfabfe32e9203fbb/proposals/0161-StringRevision1.md" class="gmail_msg" target="_blank">https://github.com/airspeedswift/swift-evolution/blob/3a822c799011ace682712532cfabfe32e9203fbb/proposals/0161-StringRevision1.md</a></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><h1 id="m_2727145958192511728m_2073527297358318132string-revision-collection-conformance--c-interop--transcoding" style="box-sizing:border-box;font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255);margin-top:0px!important" class="gmail_msg">String Revision: Collection Conformance, C Interop, Transcoding</h1><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">Proposal:&nbsp;<a style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg">SE-0161</a></li><li style="box-sizing:border-box" class="gmail_msg">Authors:&nbsp;<a href="https://github.com/airspeedswift" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">Ben Cohen</a>,&nbsp;<a href="http://github.com/dabrahams/" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">Dave Abrahams</a></li><li style="box-sizing:border-box" class="gmail_msg">Review Manager: TBD</li><li style="box-sizing:border-box" class="gmail_msg">Status:&nbsp;<strong style="box-sizing:border-box" class="gmail_msg">Awaiting review</strong></li></ul><h2 id="m_2727145958192511728m_2073527297358318132introduction" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Introduction</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal is to implement a subset of the changes from the&nbsp;<a href="https://github.com/apple/swift/blob/master/docs/StringManifesto.md" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">Swift 4 String Manifesto</a>.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Specifically:</p><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">Make&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;conform to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">BidirectionalCollection</code></li><li style="box-sizing:border-box" class="gmail_msg">Make&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;conform to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">RangeReplaceableCollection</code></li><li style="box-sizing:border-box" class="gmail_msg">Create a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;type for&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String.SubSequence</code></li><li style="box-sizing:border-box" class="gmail_msg">Create a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>&nbsp;protocol to allow for generic operations over both types.</li><li style="box-sizing:border-box" class="gmail_msg">Consolidate on a concise set of C interop methods.</li><li style="box-sizing:border-box" class="gmail_msg"><ins id="m_2727145958192511728m_2073527297358318132firstdiff" style="box-sizing:border-box;display:inline-block;text-decoration:none!important;border:none!important;background-image:none!important;background-position:initial initial!important;background-repeat:initial initial!important" class="gmail_msg"></ins>Revise the transcoding infrastructure.</li></ul><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Other existing aspects of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;remain unchanged for the purposes of this proposal.</p><h2 id="m_2727145958192511728m_2073527297358318132motivation" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Motivation</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal follows up on a number of recommendations found in the manifesto:</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Collection</code>&nbsp;conformance was dropped from&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;in Swift 2. After reevaluation, the feeling is that the minor semantic discrepancies (mainly with&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">RangeReplaceableCollection</code>) are outweighed by the significant benefits of restoring these conformances. For more detail on the reasoning, see&nbsp;<a href="https://github.com/apple/swift/blob/master/docs/StringManifesto.md#string-should-be-a-collection-of-characters-again" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">here</a></p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">While it is not a collection, the Swift 3 string does have slicing operations.&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;is currently serving as its own subsequence, allowing substrings to share storage with their “owner”. This can lead to memory leaks when small substrings of larger strings are stored long-term (see&nbsp;<a href="https://github.com/apple/swift/blob/master/docs/StringManifesto.md#substrings" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">here</a>&nbsp;for more detail on this problem). Introducing a separate type of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;to serve as&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String.Subsequence</code>&nbsp;is recommended to resolve this issue, in a similar fashion to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">ArraySlice</code>.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">As noted in the manifesto, support for interoperation with nul-terminated C strings in Swift 3 is scattered and incoherent, with 6 ways to transform a C string into a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;and four ways to do the inverse. These APIs should be replaced with a simpler set of methods on&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>.</p><h2 id="m_2727145958192511728m_2073527297358318132proposed-solution" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Proposed solution</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">A new type,&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>, will be introduced. Similar to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">ArraySlice</code>&nbsp;it will be documented as only for short- to medium-term storage:</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 15px;color:rgb(119,119,119);border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><p style="box-sizing:border-box;margin:0px 0px 16px" class="gmail_msg"><strong style="box-sizing:border-box" class="gmail_msg">Important</strong></p><div style="box-sizing:border-box;margin:0px" class="gmail_msg">Long-term storage of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;instances is discouraged. A substring holds a reference to the entire storage of a larger string, not just to the portion it presents, even after the original string’s lifetime ends. Long-term storage of a substring may therefore prolong the lifetime of elements that are no longer otherwise accessible, which can appear to be memory leakage.</div></blockquote><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Aside from minor differences, such as having a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">SubSequence</code>&nbsp;of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Self</code>&nbsp;and a larger size to describe the range of the subsequence,&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;will be near-identical from a user perspective.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">In order to be able to write extensions accross both&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;and&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>, a new&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>&nbsp;protocol to which the two types will conform will be introduced. For the purposes of this proposal,&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>&nbsp;will be defined as a protocol to be used whenver you would previously extend&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>. It should be possible to substitute&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">extension Unicode { ... }</code>&nbsp;in Swift 4 wherever&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">extension String { ... }</code>&nbsp;was written in Swift 3, with one exception: any passing of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">self</code>&nbsp;into an API that takes a concrete&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;will need to be rewritten as&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String(self)</code>. If&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Self</code>&nbsp;is a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;then this should effectively optimize to a no-op, whereas if&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Self</code>&nbsp;is a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;then this will force a copy, helping to avoid the “memory leak” problems described above.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The exact nature of the protocol – such as which methods should be protocol requirements vs which can be implemented as protocol extensions, are considered implementation details and so not covered in this proposal.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>&nbsp;will conform to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">BidirectionalCollection</code>.&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">RangeReplaceableCollection</code>&nbsp;conformance will be added directly onto the&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;and&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;types, as it is possible future&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>-conforming types might not be range-replaceable (e.g. an immutable type that wraps a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">const char *</code>).</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The C string interop methods will be updated to those described&nbsp;<a href="https://github.com/apple/swift/blob/master/docs/StringManifesto.md#c-string-interop" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">here</a>: a single&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">withCString</code>&nbsp;operation and two&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">init(cString:)</code>&nbsp;constructors, one for UTF8 and one for arbitrary encodings. The primary change is to remove “non-repairing” variants of construction from nul-terminated C strings. In both of the construction APIs, any invalid encoding sequence detected will have its longest valid prefix replaced by&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">U+FFFD</code>, the Unicode replacement character, per the Unicode specification. This covers the common case. The replacement is done physically in the underlying storage and the validity of the result is recorded in the String’s encoding such that future accesses need not be slowed down by possible error repair separately. Construction that is aborted when encoding errors are detected can be accomplished using APIs on the encoding.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The current transcoding support will be updated to improve usability and performance. The primary changes will be:</p><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">to allow transcoding directly from one encoding to another without having to triangulate through an intermediate scalar value</li><li style="box-sizing:border-box" class="gmail_msg">to add the ability to transcode an input collection in reverse, allowing the different views on&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;to be made bi-directional</li><li style="box-sizing:border-box" class="gmail_msg">to have decoding take a collection rather than an iterator, and return an index of its progress into the source, allowing that method to be static</li></ul><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The standard library currently lacks a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Latin1</code>&nbsp;codec, so a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">enum Latin1: UnicodeEncoding</code>&nbsp;type will be added.</p><h2 id="m_2727145958192511728m_2073527297358318132detailed-design" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Detailed design</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The following additions will be made to the standard library:</p><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:248px" class="gmail_msg"><code class="m_2727145958192511728m_2073527297358318132hljs m_2727145958192511728m_2073527297358318132swift gmail_msg" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">protocol</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">BidirectionalCollection</span> </span>{
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// Implementation detail as described above</span>
}

<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>, <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">RangeReplaceableCollection</span> </span>{
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">typealias</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> = <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>
}

<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">struct</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>, <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">RangeReplaceableCollection</span> </span>{
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">typealias</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> = <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// near-identical API surface area to String</span>
}</code></pre><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The subscript operations on&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;will be amended to return&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>:</p><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:112px" class="gmail_msg"><code class="m_2727145958192511728m_2073527297358318132hljs m_2727145958192511728m_2073527297358318132swift gmail_msg" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">struct</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Range</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;) -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span> { <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">get</span> }
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ClosedRange</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;) -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span> { <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">get</span> }
}</code></pre><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Note that properties or methods that due to their nature create new&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;storage (such as&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">lowercased()</code>) will&nbsp;<em style="box-sizing:border-box" class="gmail_msg">not</em>&nbsp;change.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">C string interop will be consolidated on the following methods:</p><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:418px" class="gmail_msg"><code class="m_2727145958192511728m_2073527297358318132hljs m_2727145958192511728m_2073527297358318132swift gmail_msg" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Constructs a `String` having the same contents as `nulTerminatedUTF8`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// - Parameter nulTerminatedUTF8: a sequence of contiguous UTF-8 encoded </span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   bytes ending just before the first zero byte (NUL character).</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">init</span>(cString nulTerminatedUTF8: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnsafePointer</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">CChar</span>&gt;)
  
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Constructs a `String` having the same contents as `nulTerminatedCodeUnits`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// - Parameter nulTerminatedCodeUnits: a sequence of contiguous code units in</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   the given `encoding`, ending just before the first zero code unit.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// - Parameter encoding: describes the encoding in which the code units</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   should be interpreted.</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">init</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span>&gt;(
    cString nulTerminatedCodeUnits: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnsafePointer</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">CodeUnit</span>&gt;,
    encoding: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>)
    
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Invokes the given closure on the contents of the string, represented as a</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// pointer to a null-terminated sequence of UTF-8 code units.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">withCString</span>&lt;Result&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> body: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(UnsafePointer&lt;CChar&gt;)</span></span></span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span> -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Result</span>) <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Result</span>
}</code></pre><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Additionally, the current ability to pass a Swift&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;into C methods that take a C string will remain as-is.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">A new protocol,&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">UnicodeEncoding</code>, will be added to replace the current&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">UnicodeCodec</code>&nbsp;protocol:</p><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:1353px" class="gmail_msg"><code class="m_2727145958192511728m_2073527297358318132hljs m_2727145958192511728m_2073527297358318132swift gmail_msg" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">enum</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeParseResult</span>&lt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">T</span>, <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt; </span>{
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Indicates valid input was recognized.</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// `resumptionPoint` is the end of the parsed region</span>
<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> valid(<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">T</span>, resumptionPoint: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>)  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-doctag" style="box-sizing:border-box;color:rgb(221,17,68)">FIXME:</span> should these be reordered?</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Indicates invalid input was recognized.</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// `resumptionPoint` is the next position at which to continue parsing after</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// the invalid input is repaired.</span>
<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> error(resumptionPoint: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>)

<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Indicates that there was no more input to consume.</span>
<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> emptyInput

  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// If any input was consumed, the point from which to continue parsing.</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">var</span> resumptionPoint: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>? {
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">switch</span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">self</span> {
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .valid(<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span>,<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">let</span> r): <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> r
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .error(<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">let</span> r): <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> r
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .emptyInput: <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_2727145958192511728m_2073527297358318132hljs-literal gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">nil</span>
    }
  }
}

<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// An encoding for text with UnicodeScalar as a common currency type</span>
<span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">protocol</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span> </span>{
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// The maximum number of code units in an encoded unicode scalar value</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">var</span> maxLengthOfEncodedScalar: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span> { <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">get</span> }
  
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// A type that can represent a single UnicodeScalar as it is encoded in this</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// encoding.</span>
  associatedtype <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span> : <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalarProtocol</span>

  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Produces a scalar of this encoding if possible; returns `nil` otherwise.</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">encode</span>&lt;Scalar: EncodedScalarProtocol&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span>:Scalar)</span></span> -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Self</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>?
  
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Parse a single unicode scalar forward from `input`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// - Parameter knownCount: a number of code units known to exist in `input`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   **Note:** passing a known compile-time constant is strongly advised,</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   even if it's zero.</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseScalarForward</span>&lt;C: Collection&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C, knownCount: Int <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/* = 0, via extension */</span>
  )</span></span> -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ParseResult</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>, <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span>

  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Parse a single unicode scalar in reverse from `input`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// - Parameter knownCount: a number of code units known to exist in `input`.</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   **Note:** passing a known compile-time constant is strongly advised,</span>
  <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///   even if it's zero.</span>
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseScalarReverse</span>&lt;C: BidirectionalCollection&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C, knownCount: Int <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/* = 0 , via extension */</span>
  )</span></span> -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ParseResult</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>, <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span>
}

<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Parsing multiple unicode scalar values</span>
<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span> </span>{
  @discardableResult
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseForward</span>&lt;C: Collection&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C,
    repairingIllFormedSequences makeRepairs: Bool = <span class="m_2727145958192511728m_2073527297358318132hljs-literal gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">true</span>,
    into output: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(EncodedScalar)</span></span></span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span>-&gt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Void</span>
  ) <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -&gt; (remainder: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>, errorCount: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span>)
  
  @discardableResult    
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseReverse</span>&lt;C: BidirectionalCollection&gt;<span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
    <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C,
    repairingIllFormedSequences makeRepairs: Bool = <span class="m_2727145958192511728m_2073527297358318132hljs-literal gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">true</span>,
    into output: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(EncodedScalar)</span></span></span> <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span>-&gt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Void</span>
  ) <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -&gt; (remainder: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>, errorCount: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span>)
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> : <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">BidirectionalCollection</span>,
        <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> == <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>,
        <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span>
}</code></pre><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">UnicodeCodec</code>&nbsp;will be updated to refine&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">UnicodeEncoding</code>, and all existing codecs will conform to it.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Note, depending on whether this change lands before or after some of the generics features, generic&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">where</code>&nbsp;clauses may need to be added temporarily.</p><h2 id="m_2727145958192511728m_2073527297358318132source-compatibility" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Source compatibility</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Adding collection conformance to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;should not materially impact source stability as it is purely additive: Swift 3’s&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;interface currently fulfills all of the requirements for a bidirectional range replaceable collection.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Altering&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>’s slicing operations to return a different type is source breaking. The following mitigating steps are proposed:</p><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg"><p style="box-sizing:border-box;margin:16px 0px" class="gmail_msg">Add a deprecated subscript operator that will run in Swift 3 compatibility mode and which will return a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;not a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>.</p></li><li style="box-sizing:border-box" class="gmail_msg"><p style="box-sizing:border-box;margin:16px 0px" class="gmail_msg">Add deprecated versions of all current slicing methods to similarly return a&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>.</p></li></ul><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">i.e.:</p><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:231px" class="gmail_msg"><code class="m_2727145958192511728m_2073527297358318132hljs m_2727145958192511728m_2073527297358318132swift gmail_msg" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
  <span class="m_2727145958192511728m_2073527297358318132hljs-meta gmail_msg" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">@available</span>(swift, obsoleted: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">4</span>)
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Range</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;) -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> {
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>(characters[bounds])
  }

  <span class="m_2727145958192511728m_2073527297358318132hljs-meta gmail_msg" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">@available</span>(swift, obsoleted: <span class="gmail_msg m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">4</span>)
  <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ClosedRange</span>&lt;<span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>&gt;) -&gt; <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> {
    <span class="m_2727145958192511728m_2073527297358318132hljs-keyword gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_2727145958192511728m_2073527297358318132hljs-type gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>(characters[bounds])
  }
}</code></pre><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">In a review of 77 popular Swift projects found on GitHub, these changes resolved any build issues in the 12 projects that assumed an explicit&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;type returned from slicing operations.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Due to the change in internal implementation, this means that these operations will be&nbsp;<em style="box-sizing:border-box" class="gmail_msg">O(n)</em>&nbsp;rather than&nbsp;<em style="box-sizing:border-box" class="gmail_msg">O(1)</em>. This is not expected to be a major concern, based on experiences from a similar change made to Java, but projects will be able to work around performance issues without upgrading to Swift 4 by explicitly typing slices as&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>, which will call the Swift 4 variant, and which will be available but not invoked by default in Swift 3 mode.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">The C string interoperability methods outside the ones described in the detailed design will remain in Swift 3 mode, be deprecated in Swift 4 mode, and be removed in a subsequent release.&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">UnicodeCodec</code>&nbsp;will be similarly deprecated.</p><h2 id="m_2727145958192511728m_2073527297358318132effect-on-abi-stability" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Effect on ABI stability</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">As a fundamental currency type for Swift, it is essential that the&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;type (and its associated subsequence) is in a good long-term state before being locked down when Swift declares ABI stability. Shrinking the size of&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;to be 64 bits is an important part of this.</p><h2 id="m_2727145958192511728m_2073527297358318132effect-on-api-resilience" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Effect on API resilience</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">Decisions about the API resilience of the&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;type are still to be determined, but are not adversely affected by this proposal.</p><h2 id="m_2727145958192511728m_2073527297358318132alternatives-considered" style="box-sizing:border-box;margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;color:rgb(51,51,51);padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);font-family:helvetica,arial,freesans,clean,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Alternatives considered</h2><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">For a more in-depth discussion of some of the trade-offs in string design, see the manifesto and associated&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170116/thread.html#30497" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="gmail_msg" target="_blank">evolution thread</a>.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal does not yet introduce an implicit conversion from&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Substring</code>&nbsp;to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>. The decision on whether to add this will be deferred pending feedback on the initial implementation. The intention is to make a preview toolchain available for feedback, including on whether this implicit conversion is necessary, prior to the release of Swift 4.</p><div style="box-sizing:border-box;margin-top:0px;margin-right:0px;margin-left:0px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:12.799999237060547px;background-color:rgb(255,255,255);margin-bottom:0px!important" class="gmail_msg">Several of the types related to&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>, such as the encodings, would ideally reside inside a namespace rather than live at the top level of the standard library. The best namespace for this is probably&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Unicode</code>, but this is also the name of the protocol. At some point if we gain the ability to nest enums and types inside protocols, they should be moved there. Putting them inside&nbsp;<code style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:10.880000114440918px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>&nbsp;or some other enum namespace is probably not worthwhile in the mean-time.</div></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></div>
</div></blockquote></div><br class=""></body></html>