<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}
h1 {
        color: #000000;
        font-size: 28pt;
}
h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}
h3 {
        font-size: 18px;
}
h4 {
        font-size: 16px;
}
h5 {
        font-size: 14px;
}
h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}
hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
display: inherit;
}
p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}
a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}
#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}
button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}
code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}
code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}
pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}
pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}
#ws { background-color: #f8f8f8; }
.bloop_markdown table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }
.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }
.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.bloop_markdown blockquote{
border-left: 4px solid #dddddd;
padding: 0 15px;
color: #777777; }
blockquote > :first-child {
margin-top: 0; }
blockquote > :last-child {
margin-bottom: 0; }
code, pre, #ws, #message {
word-break: normal;
word-wrap: normal;
}
hr {
display: inherit;
}
.bloop_markdown :first-child {
-webkit-margin-before: 0;
}
code, pre, #ws, #message {
font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>If I had to choose as a not native English speaker I’d go for <code>SubString</code> just for the camel case consistency across all other types.</p>
<p>We cannot rename <code>SubSequence</code> to <code>Subsequence</code>, because that would be odd compared to all other types containing <code>Sequence</code>.</p>
<ul>
<li>AnySequence</li>
<li>LazyPrefixWhileSequence</li>
<li>LazySequence</li>
<li>EnumeratedSequence</li>
<li>etc.</li>
</ul>
<p>This won’t break anything or create any other inconsistency.</p>
<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1490889278491198976" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 30. März 2017 um 17:51:09, Joshua Alvarado via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<title></title>
<div dir="ltr">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
...<span style="font-size:12.800000190734863px">my vote would be to
lowercase Subsequence. We can typealias SubSequence = Subsequence
to aid migration</span></blockquote>
<div> </div>
+1 didn't think that was an option. A good solution would be to
have them either camel case (SubString, SubSequence) or just
capitalized (Substring, Substring) either would be nice as
long as they were matching.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Mar 30, 2017 at 9:38 AM, Ben Cohen
via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;line-break:after-white-space">
<br>
<div>
<blockquote type="cite">
<div><span class="">On Mar 29, 2017, at 6:59 PM, Xiaodi Wu
<<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>> wrote:</span></div>
<span class=""><br class="m_6647696270961860142Apple-interchange-newline"></span>
<div>
<div><span class="">This looks great. The restored conformances to
*Collection will be huge.</span></div>
<div><span class=""><br></span></div>
<div><span 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="m_6647696270961860142gmail_msg">
<br class="m_6647696270961860142gmail_msg"></span></div>
</div>
</blockquote>
<div><span class=""><br></span></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>
<span class=""><br></span>
<blockquote type="cite">
<div>
<div><span class="">Nits on naming: are we calling it Substring or
SubString (à la SubSequence)?</span></div>
</div>
</blockquote>
<div><span class=""><br></span></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></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>might</i> 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. 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 sequence that can be derived from another
sequence by deleting some elements without changing the order of
the remaining elements" e.g. <A,C,E> is a Subsequence of
<A,B,C,D,E> – see <a href="https://en.wikipedia.org/wiki/Subsequence" target="_blank">https://en.wikipedia.org/<wbr>wiki/Subsequence</a>).
Even worse, the mathematical term for what we are calling a
subsequence is a Substring!</div>
<div><br></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>
<span class=""><br></span>
<blockquote type="cite">
<div>
<div><span class="">and shouldn't it be UnicodeParsedResult rather
than UnicodeParseResult?</span></div>
<div><span class=""><br></span></div>
</div>
</blockquote>
<div><span class=""><br></span></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>
<div>
<div class="h5"><br>
<blockquote type="cite">
<div>
<div><br class="m_6647696270961860142gmail_msg">
<div class="gmail_quote m_6647696270961860142gmail_msg">
<div class="m_6647696270961860142gmail_msg">On Wed, Mar 29, 2017 at
19:32 Ben Cohen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="m_6647696270961860142gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="m_6647696270961860142gmail_msg"></div>
<blockquote class="gmail_quote m_6647696270961860142gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word" class="m_6647696270961860142gmail_msg">Hi Swift Evolution,
<div class="m_6647696270961860142gmail_msg"><br class="m_6647696270961860142gmail_msg"></div>
<div class="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg"><br class="m_6647696270961860142gmail_msg"></div>
<div class="m_6647696270961860142gmail_msg">Online version
here: <a href="https://github.com/airspeedswift/swift-evolution/blob/3a822c799011ace682712532cfabfe32e9203fbb/proposals/0161-StringRevision1.md" class="m_6647696270961860142gmail_msg" target="_blank">https://github.com/<wbr>airspeedswift/swift-evolution/<wbr>blob/<wbr>3a822c799011ace682712532cfabfe<wbr>32e9203fbb/proposals/0161-<wbr>StringRevision1.md</a></div>
<div class="m_6647696270961860142gmail_msg"><br class="m_6647696270961860142gmail_msg"></div>
<div class="m_6647696270961860142gmail_msg"><br class="m_6647696270961860142gmail_msg"></div>
<div class="m_6647696270961860142gmail_msg">
<h1 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Proposal: <a style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="m_6647696270961860142gmail_msg">SE-0161</a></li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Authors: <a href="https://github.com/airspeedswift" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="m_6647696270961860142gmail_msg" target="_blank">Ben
Cohen</a>, <a href="http://github.com/dabrahams/" style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="m_6647696270961860142gmail_msg" target="_blank">Dave
Abrahams</a></li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Review Manager: TBD</li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Status: <strong style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Awaiting review</strong></li>
</ul>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">This proposal is to
implement a subset of the changes from the <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Make <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="m_6647696270961860142gmail_msg">String</code> conform
to <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="m_6647696270961860142gmail_msg">BidirectionalCollection</code></li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Make <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="m_6647696270961860142gmail_msg">String</code> conform
to <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="m_6647696270961860142gmail_msg">RangeReplaceableCollection</code></li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Create a <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="m_6647696270961860142gmail_msg">Substring</code> type
for <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="m_6647696270961860142gmail_msg">String.SubSequence</code></li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Create a <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="m_6647696270961860142gmail_msg">Unicode</code> protocol
to allow for generic operations over both types.</li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Consolidate on a concise set of C
interop methods.</li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg"><ins id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Other existing aspects
of <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="m_6647696270961860142gmail_msg">String</code> remain
unchanged for the purposes of this proposal.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Collection</code> conformance
was dropped from <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="m_6647696270961860142gmail_msg">String</code> in Swift
2. After reevaluation, the feeling is that the minor semantic
discrepancies (mainly with <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="m_6647696270961860142gmail_msg">RangeReplaceableCollectio<wbr>n</code>)
are outweighed by the significant benefits of restoring these
conformances. For more detail on the reasoning, see <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">While it is not a
collection, the Swift 3 string does have slicing
operations. <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="m_6647696270961860142gmail_msg">String</code> 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 <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="m_6647696270961860142gmail_msg" target="_blank">here</a> for more detail on this problem).
Introducing a separate type of <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="m_6647696270961860142gmail_msg">Substring</code> to
serve as <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="m_6647696270961860142gmail_msg">String.Subsequence</code> is
recommended to resolve this issue, in a similar fashion
to <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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 <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="m_6647696270961860142gmail_msg">String</code> and four
ways to do the inverse. These APIs should be replaced with a
simpler set of methods on <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="m_6647696270961860142gmail_msg">String</code>.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">A new
type, <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="m_6647696270961860142gmail_msg">Substring</code>, will be
introduced. Similar to <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="m_6647696270961860142gmail_msg">ArraySlice</code> 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="m_6647696270961860142gmail_msg">
<p style="box-sizing:border-box;margin:0px 0px 16px" class="m_6647696270961860142gmail_msg"><strong style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">Important</strong></p>
<div style="box-sizing:border-box;margin:0px" class="m_6647696270961860142gmail_msg">Long-term storage
of <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="m_6647696270961860142gmail_msg">Substring</code> 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="m_6647696270961860142gmail_msg">Aside from minor
differences, such as having a <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="m_6647696270961860142gmail_msg">SubSequence</code> of <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="m_6647696270961860142gmail_msg">Self</code> and a
larger size to describe the range of the
subsequence, <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="m_6647696270961860142gmail_msg">Substring</code> 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="m_6647696270961860142gmail_msg">In order to be able to write
extensions accross both <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="m_6647696270961860142gmail_msg">String</code> and <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="m_6647696270961860142gmail_msg">Substring</code>, a
new <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="m_6647696270961860142gmail_msg">Unicode</code> protocol
to which the two types will conform will be introduced. For the
purposes of this proposal, <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="m_6647696270961860142gmail_msg">Unicode</code> will be
defined as a protocol to be used whenver you would previously
extend <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="m_6647696270961860142gmail_msg">String</code>. It should be
possible to substitute <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="m_6647696270961860142gmail_msg">extension Unicode { ...
}</code> in Swift 4 wherever <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="m_6647696270961860142gmail_msg">extension String { ...
}</code> was written in Swift 3, with one exception: any
passing of <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="m_6647696270961860142gmail_msg">self</code> into an API
that takes a concrete <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="m_6647696270961860142gmail_msg">String</code> will need
to be rewritten as <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="m_6647696270961860142gmail_msg">String(self)</code>.
If <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="m_6647696270961860142gmail_msg">Self</code> is
a <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="m_6647696270961860142gmail_msg">String</code> then this
should effectively optimize to a no-op, whereas
if <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="m_6647696270961860142gmail_msg">Self</code> is
a <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="m_6647696270961860142gmail_msg">Substring</code> 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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Unicode</code> will
conform to <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="m_6647696270961860142gmail_msg">BidirectionalCollection</code>. <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="m_6647696270961860142gmail_msg">Ra<wbr>ngeReplaceableCollection</code> <wbr>conformance
will be added directly onto the <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="m_6647696270961860142gmail_msg">String</code> and <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="m_6647696270961860142gmail_msg">Substring</code> <wbr>types,
as it is possible future <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="m_6647696270961860142gmail_msg">Unicode</code>-conforming
types might not be range-replaceable (e.g. an immutable type that
wraps a <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">The C string interop methods
will be updated to those described <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="m_6647696270961860142gmail_msg" target="_blank">here</a>: a
single <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="m_6647696270961860142gmail_msg">withCString</code> operation
and two <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="m_6647696270961860142gmail_msg">init(cString:)</code> <wbr>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 <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">to add the ability to transcode an
input collection in reverse, allowing the different views
on <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="m_6647696270961860142gmail_msg">String</code> to be
made bi-directional</li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">The standard library
currently lacks a <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="m_6647696270961860142gmail_msg">Latin1</code> codec, so
a <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="m_6647696270961860142gmail_msg">enum Latin1:
UnicodeEncoding</code> type will be added.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg"><code class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs m_6647696270961860142m_2727145958192511728m_2073527297358318132swift m_6647696270961860142gmail_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_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">protocol</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">BidirectionalCollection</span> </span>{
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// Implementation detail as described above</span>
}
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>, <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">RangeReplaceableCollection</span> </span>{
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">typealias</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> = <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>
}
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">struct</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Unicode</span>, <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">RangeReplaceableCollection</span> </span>{
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">typealias</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> = <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg">The subscript operations
on <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="m_6647696270961860142gmail_msg">String</code> will be
amended to return <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg"><code class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs m_6647696270961860142m_2727145958192511728m_2073527297358318132swift m_6647696270961860142gmail_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_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">struct</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Range</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>) -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span> { <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">get</span> }
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ClosedRange</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>) -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Substring</span> { <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Note that properties or
methods that due to their nature create new <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="m_6647696270961860142gmail_msg">String</code> storage
(such as <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="m_6647696270961860142gmail_msg">lowercased()</code>)
will <em style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">not</em> 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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg"><code class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs m_6647696270961860142m_2727145958192511728m_2073527297358318132swift m_6647696270961860142gmail_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_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">init</span>(cString nulTerminatedUTF8: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnsafePointer</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">CChar</span>>)
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// should be interpreted.</span>
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">init</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span>>(
cString nulTerminatedCodeUnits: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnsafePointer</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">CodeUni<wbr>t</span>>,
encoding: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Encoding</span>)
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">withCString</span><Result><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> body: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(UnsafePointer<CChar>)</span></span></span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span> -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Result</span>) <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Additionally, the current
ability to pass a Swift <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="m_6647696270961860142gmail_msg">String</code> 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="m_6647696270961860142gmail_msg">A new
protocol, <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="m_6647696270961860142gmail_msg">UnicodeEncoding</code>, will
be added to replace the current <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="m_6647696270961860142gmail_msg">UnicodeCodec</code> 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="m_6647696270961860142gmail_msg"><code class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs m_6647696270961860142m_2727145958192511728m_2073527297358318132swift m_6647696270961860142gmail_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">enum</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeParseResult</span><<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">T</span>, <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>> </span>{
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Indicates valid input was recognized.</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> valid(<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">T</span>, resumptionPoint: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>) <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-doctag" style="box-sizing:border-box;color:rgb(221,17,68)">FIXME:</span> should these be reordered?</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Indicates invalid input was recognized.</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> error(resumptionPoint: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>)
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> emptyInput
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">var</span> resumptionPoint: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>? {
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">switch</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">self</span> {
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .valid(<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span>,<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">let</span> r): <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> r
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .error(<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">let</span> r): <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> r
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">case</span> .emptyInput: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-literal m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">nil</span>
}
}
}
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">protocol</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span> </span>{
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">var</span> maxLengthOfEncodedScalar: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span> { <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">get</span> }
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// encoding.</span>
associatedtype <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span> : <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalarProtocol</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">encode</span><Scalar: EncodedScalarProtocol><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span>:Scalar)</span></span> -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Self</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>?
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseScalarForward</span><C: Collection><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C, knownCount: Int <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/* = 0, via extension */</span>
)</span></span> -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ParseResult</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>, <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">///</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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="m_6647696270961860142gmail_msg m_6647696270961860142m_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_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseScalarReverse</span><C: BidirectionalCollection><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C, knownCount: Int <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/* = 0 , via extension */</span>
)</span></span> -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ParseResult</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>, <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span>
}
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">/// Parsing multiple unicode scalar values</span>
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">UnicodeEncoding</span> </span>{
@discardableResult
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseForward</span><C: Collection><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C,
repairingIllFormedSequences makeRepairs: Bool = <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-literal m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">true</span>,
into output: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(EncodedScalar)</span></span></span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span>-><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Void</span>
) <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -> (remainder: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>, errorCount: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span>)
@discardableResult
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">public</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">static</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-function" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">func</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold">parseReverse</span><C: BidirectionalCollection><span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(
<span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">_</span> input: C,
repairingIllFormedSequences makeRepairs: Bool = <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-literal m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(0,128,128)">true</span>,
into output: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-params" style="box-sizing:border-box">(EncodedScalar)</span></span></span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">throws</span>-><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Void</span>
) <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">rethrows</span> -> (remainder: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>, errorCount: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Int</span>)
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">where</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> : <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">BidirectionalCollection</span>,
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span> == <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>,
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">C</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">SubSequence</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Element</span> == <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">EncodedScalar</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Iterator</span>.<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">UnicodeCodec</code> will be
updated to refine <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Note, depending on whether
this change lands before or after some of the generics features,
generic <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="m_6647696270961860142gmail_msg">where</code> clauses
may need to be added temporarily.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Adding collection
conformance to <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="m_6647696270961860142gmail_msg">String</code> should
not materially impact source stability as it is purely additive:
Swift 3’s <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="m_6647696270961860142gmail_msg">String</code> 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="m_6647696270961860142gmail_msg">Altering <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">
<p style="box-sizing:border-box;margin:16px 0px" class="m_6647696270961860142gmail_msg">Add a deprecated subscript
operator that will run in Swift 3 compatibility mode and which will
return a <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="m_6647696270961860142gmail_msg">String</code> not
a <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="m_6647696270961860142gmail_msg">Substring</code>.</p>
</li>
<li style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">
<p style="box-sizing:border-box;margin:16px 0px" class="m_6647696270961860142gmail_msg">Add deprecated versions of all
current slicing methods to similarly return a <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg"><code class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs m_6647696270961860142m_2727145958192511728m_2073527297358318132swift m_6647696270961860142gmail_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_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-class" style="box-sizing:border-box"><span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">extension</span> <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> </span>{
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-meta m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">@available</span>(swift, obsoleted: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">4</span>)
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Range</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>) -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> {
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span>(characters[bounds])
}
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-meta m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">@available</span>(swift, obsoleted: <span class="m_6647696270961860142gmail_msg m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">4</span>)
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">subscript</span>(bounds: <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">ClosedRange</span><<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">Index</span>>) -> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_msg" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">String</span> {
<span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-keyword m_6647696270961860142gmail_msg" style="box-sizing:border-box;font-weight:bold">return</span> <span class="m_6647696270961860142m_2727145958192511728m_2073527297358318132hljs-type m_6647696270961860142gmail_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="m_6647696270961860142gmail_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 <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="m_6647696270961860142gmail_msg">String</code> 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="m_6647696270961860142gmail_msg">Due to the change in
internal implementation, this means that these operations will
be <em style="box-sizing:border-box" class="m_6647696270961860142gmail_msg">O(n)</em> rather
than <em style="box-sizing:border-box" class="m_6647696270961860142gmail_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 <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_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. <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="m_6647696270961860142gmail_msg">UnicodeCodec</code> will be
similarly deprecated.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">As a fundamental currency
type for Swift, it is essential that the <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="m_6647696270961860142gmail_msg">String</code> 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 <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="m_6647696270961860142gmail_msg">String</code> to be 64
bits is an important part of this.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Decisions about the API
resilience of the <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="m_6647696270961860142gmail_msg">String</code> type are
still to be determined, but are not adversely affected by this
proposal.</p>
<h2 id="m_6647696270961860142m_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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">For a more in-depth
discussion of some of the trade-offs in string design, see the
manifesto and associated <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">This proposal does not yet
introduce an implicit conversion from <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="m_6647696270961860142gmail_msg">Substring</code> to <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="m_6647696270961860142gmail_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="m_6647696270961860142gmail_msg">Several of the types related
to <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="m_6647696270961860142gmail_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 <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="m_6647696270961860142gmail_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 <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="m_6647696270961860142gmail_msg">String</code> or some
other enum namespace is probably not worthwhile in the
mean-time.</div>
</div>
</div>
______________________________<wbr>_________________<br class="m_6647696270961860142gmail_msg">
swift-evolution mailing list<br class="m_6647696270961860142gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="m_6647696270961860142gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_6647696270961860142gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_6647696270961860142gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br class="m_6647696270961860142gmail_msg">
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<br></div>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote>
</div>
<br>
<br clear="all">
<div><br></div>
--<br>
<div class="gmail_signature" data-smartmail="gmail_signature">
Joshua Alvarado
<div><a href="mailto:alvaradojoshua0@gmail.com" target="_blank">alvaradojoshua0@gmail.com</a></div>
</div>
</div>
_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>