<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 7 Feb 2017, at 19:44, Dave Abrahams <<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">on Tue Feb 07 2017, "Ted F.A. van Gaalen" <<a href="http://tedvgiosdev-AT-gmail.com" class="">tedvgiosdev-AT-gmail.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On 7 Feb 2017, at 05:42, Karl Wagner <<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class="">On 6 Feb 2017, at 19:29, Ted F.A. van Gaalen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></blockquote></blockquote><<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>>> wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""></blockquote>When it comes to fast access what’s most important is cache<br class="">locality. DRAM is like 200x slower than L2 cache. Looping through<br class="">some contiguous 16-bit integers is always going to beat the pants<br class="">out of derefencing pointers.<br class=""></blockquote><br class=""><blockquote type="cite" class=""><br class=""></blockquote>Hi Karl<br class="">That is of course hardware/processor dependent…and Swift runs on different target systems… isn’t? <br class=""></blockquote><br class="">Actually the basic calculus holds for any modern processor.<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">It’s quite rare that you need to grab arbitrary parts of a String<br class="">without knowing what is inside it. If you’re saying str[12..<34] -<br class="">why 12, and why 34? Is 12 the length of some substring you know from<br class="">earlier? In that case, you could find out how many CodeUnits it had,<br class="">and use that information instead.<br class="">For this example, I have used constants here, but normally these would be variables..<br class=""><br class=""></blockquote><br class="">I’d say it is not so rare, these things are often used for all kinds of string parsing, there are<br class="">many<br class="">examples to be found on the Internet.<br class="">TedvG<br class=""></blockquote><br class="">That proves nothing, though. The fact that people are using integers to<br class="">do this doesn't mean you need to use them, nor does it mean that you'll<br class="">get the right results from doing so. Typically examples that use<br class="">integer constants with strings are wrong for some large proportion of<br class="">unicode text.<br class=""><br class=""></div></div></blockquote> This is all a bit confusing. </div><div>in <a href="https://en.wiktionary.org/wiki/glyph" class="">https://en.wiktionary.org/wiki/glyph</a><br class=""> Definition of a glyph in our context: <br class=""><ol style="margin: 0.3em 0px 0px 3.2em; padding: 0px; list-style-image: none; color: rgb(37, 37, 37); font-family: sans-serif;" class=""><li style="margin-bottom: 0.1em; page-break-inside: avoid; break-inside: avoid; -webkit-column-break-inside: avoid;" class=""><span class="ib-brac">(</span><span class="ib-content" style="font-style: italic;">typography<span class="ib-comma" style="font-style: normal;">,</span> computing</span><span class="ib-brac">)</span> A visual representation of a <a href="https://en.wiktionary.org/wiki/letter" title="letter" style="text-decoration: none; color: rgb(11, 0, 128); background-image: none; background-position: initial initial; background-repeat: initial initial;" class="">letter</a>, <a href="https://en.wiktionary.org/wiki/character" title="character" style="text-decoration: none; color: rgb(11, 0, 128); background-image: none; background-position: initial initial; background-repeat: initial initial;" class="">character</a>, or <a href="https://en.wiktionary.org/wiki/symbol" title="symbol" style="text-decoration: none; color: rgb(11, 0, 128); background-image: none; background-position: initial initial; background-repeat: initial initial;" class="">symbol</a>, in a specific <a href="https://en.wiktionary.org/wiki/font" title="font" style="text-decoration: none; color: rgb(11, 0, 128); background-image: none; background-position: initial initial; background-repeat: initial initial;" class="">font</a> and <a href="https://en.wiktionary.org/wiki/style" title="style" style="text-decoration: none; color: rgb(11, 0, 128); background-image: none; background-position: initial initial; background-repeat: initial initial;" class="">style</a>.</li></ol><div class=""><font color="#252525" face="sans-serif" class=""><br class=""></font></div><div class=""><font color="#252525" face="sans-serif" class="">I now assume that:</font></div><div class=""><font color="#252525" face="sans-serif" class=""> 1. -= a “plain” Unicode character (codepoint?) can result in one glyph.=-</font></div><div class=""><font color="#252525" face="sans-serif" class=""> 2. -= a grapheme cluster always results in just a single glyph, true? =- </font></div><div class=""><font color="#252525" face="sans-serif" class=""> 3. The only thing that I can see on screen or print are glyphs (“carvings”,visual elements that stand on their own )</font></div><div class=""><font color="#252525" face="sans-serif" class=""> 4. In this context, a glyph is a humanly recognisable visual form of a character,</font></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""> 5. On this level (the glyph, what I can see as a user) it is not relevant and also not detectable</span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""> with how many Unicode scalars (codepoints ?), grapheme, or even on what kind</span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""> of encoding the glyph was based upon.</span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""><br class=""></span></div><div class=""><font color="#252525" face="sans-serif" class=""> is this correct? (especially 1 and 2) </font></div><div class=""><font color="#252525" face="sans-serif" class=""><br class=""></font></div><div class=""><font color="#252525" face="sans-serif" class="">Based on these assumptions, to me then, the definition of a character == glyph.</font></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class="">Therefore, my working model: I see a row of characters as a row of glyphs,</span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class="">which are discrete autonomous visual elements, ergo: </span></div><div class=""><font color="#252525" face="sans-serif" class="">Each element is individually addressable with integers (ordinal)</font></div><div class=""><br class=""></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class="">?</span></div><div class=""><br class=""></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class="">TedvG</span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""><br class=""></span></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><span style="color: rgb(37, 37, 37); font-family: sans-serif;" class=""> </span></div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="">-- <br class="">-Dave<br class=""></div></div></blockquote></div><br class=""></body></html>