<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br><div>Sent from my moss-covered three-handled family gradunza</div></div><div><br>On Feb 9, 2017, at 3:45 PM, Hooman Mehr &lt;<a href="mailto:hooman@mac.com">hooman@mac.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 9, 2017, at 3:11 PM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">on Thu Feb 09 2017, "Ted F.A. van Gaalen" &lt;<a href="http://tedvgiosdev-AT-gmail.com" class="">tedvgiosdev-AT-gmail.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">Hello Shawn<br class="">Just google with any programming language name and “string manipulation”<br class="">and you have enough reading for a week or so :o)<br class="">TedvG<br class=""></blockquote><br class="">That truly doesn't answer the question. &nbsp;It's not, “why do people index<br class="">strings with integers when that's the only tool they are given for<br class="">decomposing strings?” &nbsp;It's, “what do you have to do with strings that's<br class="">hard in Swift *because* you can't index them with integers?”<br class=""></div></div></blockquote><div><br class=""></div><div>I have done some string processing. I have not encountered any algorithm where an integer index is absolutely needed, but sometimes it might be the most convenient.&nbsp;</div><div><br class=""></div><div>For example, there are valid reasons to keep side tables that hold indexes into a string. (such as maintaining attributes that apply to a substring or things like pre-computed positions of soft line breaks). It does not require the index to be <b class="">integer</b>, but maintaining validity of those indexes after the string is mutated requires being able to offset them back or forth from some position on. These operations could be less verbose and easier if the index happens to be integer or (efficiently) supports + - operators. Also, I know there are other methods to deal with such things and mutating a large string generally is a bad idea, but sometimes it is the easiest and most convenient solution to the problem at hand.</div></div></div></div></blockquote><div><br></div>As noted in the manifesto, it will be trivial to translate string indices to/from integer code unit offsets, most likely by a property / an init<div><br></div><div>String indices as proposed will not however support +/-<br><div><br><blockquote type="cite"><div><div class=""><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On 9 Feb 2017, at 16:48, Shawn Erickson &lt;<a href="mailto:shawnce@gmail.com" class="">shawnce@gmail.com</a>&gt; wrote:<br class=""><br class="">I also wonder what folks are actually doing that require indexing<br class="">into strings. I would love to see some real world examples of what<br class="">and why indexing into a string is needed. Who is the end consumer of<br class="">that string, etc.<br class=""><br class="">Do folks have so examples?<br class=""><br class="">-Shawn<br class=""><br class="">On Thu, Feb 9, 2017 at 6:56 AM Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class="">Hello Hooman<br class="">That invalidates my assumptions, thanks for evaluating<br class="">it's more complex than I thought.<br class="">Kind Regards<br class="">Ted<br class=""><br class=""><blockquote type="cite" class="">On 8 Feb 2017, at 00:07, Hooman Mehr &lt;<a href="mailto:hooman@mac.com" class="">hooman@mac.com</a> &lt;<a href="mailto:hooman@mac.com" class="">mailto:hooman@mac.com</a>&gt;&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Feb 7, 2017, at 12:19 PM, Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class=""><br class="">I now assume that:<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. -= a “plain” Unicode character (codepoint?) &nbsp;can result in one glyph.=-<br class=""></blockquote><br class="">What do you mean by “plain”? Characters in some Unicode scripts are<br class="">by no means “plain”. They can affect (and be affected by) the<br class="">characters around them, they can cause glyphs around them to<br class="">rearrange or combine (like ligatures) or their visual<br class="">representation (glyph) may float in the same space as an adjacent<br class="">glyph (and seem to be part of the “host” glyph), etc. So, the<br class="">general relationship of a character and its corresponding glyph (if<br class="">there is one) is complex and depends on context and surroundings<br class="">characters.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. -= a &nbsp;grapheme cluster always results in just a single glyph, true? =- <br class=""></blockquote><br class="">False<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. The only thing that I can see on screen or print are glyphs (“carvings”,visual elements that stand on their own )<br class=""></blockquote><br class="">The visible effect might not be a visual shape. It may be for example, the way the surrounding shapes change or re-arrange.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;4. &nbsp;In this context, a glyph is a humanly recognisable visual form of a character,<br class=""></blockquote><br class="">Not in a straightforward one to one fashion, not even in Latin / Roman script.<br class=""><br class=""><blockquote type="cite" class=""> &nbsp;&nbsp;&nbsp;&nbsp;5. On this level (the glyph, what I can see as a user) it is not relevant and also not detectable<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with how many Unicode scalars (codepoints ?), grapheme, or even on what kind<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;of encoding the glyph was based upon.<br class=""></blockquote><br class="">False<br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;<br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote>&lt;<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a>&gt;<br class=""><br class=""></blockquote><br class="">-- <br class="">-Dave<br class=""></div></div></blockquote></div><br class=""></div></div></blockquote></div></div></body></html>