<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 &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 Tue Feb 07 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=""><blockquote type="cite" class="">On 7 Feb 2017, at 05:42, Karl Wagner &lt;<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>&gt; 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 &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></blockquote></blockquote>&lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; 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..&lt;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. &nbsp;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. &nbsp;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>&nbsp; This is all a bit confusing. &nbsp;</div><div>in&nbsp;<a href="https://en.wiktionary.org/wiki/glyph" class="">https://en.wiktionary.org/wiki/glyph</a><br class="">&nbsp; &nbsp;Definition of a glyph in our context:&nbsp;<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>&nbsp;computing</span><span class="ib-brac">)</span>&nbsp;A visual representation of a&nbsp;<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>,&nbsp;<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&nbsp;<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&nbsp;<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>&nbsp;and&nbsp;<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="">&nbsp; &nbsp; &nbsp; 1. -= a “plain” Unicode character (codepoint?) &nbsp;can result in one glyph.=-</font></div><div class=""><font color="#252525" face="sans-serif" class="">&nbsp; &nbsp; &nbsp; 2. -= a &nbsp;grapheme cluster always results in just a single glyph, true? =-&nbsp;</font></div><div class=""><font color="#252525" face="sans-serif" class="">&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 )</font></div><div class=""><font color="#252525" face="sans-serif" class="">&nbsp; &nbsp; &nbsp;4. &nbsp;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="">&nbsp; &nbsp; &nbsp;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="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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="">&nbsp;is this correct? (especially 1 and 2)&nbsp;</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:&nbsp;</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="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</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>