<div dir="ltr">Jorg wrote:--<div>> So, Text has a cache of the last found position (org = 3256, and pce is the piece, where postion "org" is in). If you search for the piece where the 3260th character is in, you start from this cache instead from position 0 again.</div><div>--------</div><div>? That's why *nix is much faster for the immediate repeat of any</div><div>text-searching, eg:</div><div> locate <token></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 26, 2018 at 2:53 AM, Jörg <span dir="ltr"><<a href="mailto:joerg.straube@iaeth.ch" target="_blank">joerg.straube@iaeth.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Peter E.<br>
<br>
<br>
<br>
If you implemented Text as ONE contiguous block in memory, then you would have to move a lot of memory around if you insert or delete text.<br>
<br>
To overcome this: We introduce the idea of piece; a piece is a contiguous block of text (characters) in memory. A Text is a list of pieces.<br>
<br>
So, if you read-in an ASCII text from a file, the Text consist (in the beginning) of only ONE piece; all the ASCII characters are contiguous in memory and represented by one piece.<br>
<br>
Now, if you eg delete char 300 to 309 of that text, this one starting piece is spilt in two: first piece points to characters 1..299 the other piece points to 310..end. So, you deleted 10 characters without moving any memory around.<br>
<br>
<br>
<br>
BTW: the two fields "pce" and "org" are not "pointers in a translation cache", they are the cache. This cache is a minor implementation detail (optimization) of "FindPiece" and not so important to understand the idea. When you want to find the 3256th character in the Text, you basically have to go through all pieces in the list one by one and add up the piece's length until the sum is larger than 3256. Then you found the piece, where the 3256th character is in.<br>
<br>
As it is very often the case that you move the cursor back and forth or up and down, it is handy not do the whole piece length summation again and again. So, Text has a cache of the last found position (org = 3256, and pce is the piece, where postion "org" is in). If you search for the piece where the 3260th character is in, you start from this cache instead from position 0 again.<br>
<br>
<br>
<br>
br<br>
<br>
Jörg<br>
<br>
<br>
<br>
Am 26.07.18, 07:57 schrieb "Jörg" <<a href="mailto:joerg.straube@iaeth.ch">joerg.straube@iaeth.ch</a>>:<br>
<span class="im HOEnZb"><br>
<br>
<br>
Peter E.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
You have a "strange" approach: On one hand you want to understand high level things like concepts and abstractions and on the other hand you go down to low level things like memory used.<br>
<br>
<br>
<br>
In my whole career I was only interested in the nbr of bytes and internal element memory alignment rules when I wrote compilers.<br>
<br>
<br>
<br>
In my point of view, it's not too useful to understand Texts when you know how much memory a Piece occupies. This memory thingy heavily depends on the compiler not on the language and not on the module you want to understand.<br>
<br>
<br>
<br>
BTW: you always can find the nbr of bytes used by a type T by using size := SYSTEM.SIZE(T);<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Before going down to this detail, it is more important to understand this model:<br>
<br>
<br>
<br>
<a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/<wbr>Model–view–controller</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
This basic mechanism of separating data from user interface is used by Texts (data model) and TextFrames (user interface).<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
And you should read this documentation:<br>
<br>
<br>
<br>
<a href="https://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.System.pdf" rel="noreferrer" target="_blank">https://www.inf.ethz.ch/<wbr>personal/wirth/ProjectOberon/<wbr>PO.System.pdf</a><br>
<br>
<br>
<br>
- Figure 2.2 gives you an view on how the kernel modules are layered.<br>
<br>
<br>
<br>
- Chapter 5 explains Texts and its piece editor in detail.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
br<br>
<br>
<br>
<br>
Jörg<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Am 26.07.18, 06:44 schrieb "<a href="mailto:oberon-bounces@lists.inf.ethz.ch">oberon-bounces@lists.inf.<wbr>ethz.ch</a> im Auftrag von <a href="mailto:peter@easthope.ca">peter@easthope.ca</a>" <<a href="mailto:oberon-bounces@lists.inf.ethz.ch">oberon-bounces@lists.inf.<wbr>ethz.ch</a> im Auftrag von <a href="mailto:peter@easthope.ca">peter@easthope.ca</a>>:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5"> Hi,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
For me, one the bigger difficulties in understanding the system is <br>
<br>
<br>
<br>
from the multiple layers of abstraction. An intention in <br>
<br>
<br>
<br>
<a href="https://en.wikibooks.org/wiki/Oberon#Oberon_Text" rel="noreferrer" target="_blank">https://en.wikibooks.org/wiki/<wbr>Oberon#Oberon_Text</a> <br>
<br>
<br>
<br>
is to encapsulate abstractions concisely together.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Understanding the relationship of an abstraction to something concrete <br>
<br>
<br>
<br>
can also help. Hence the "Memory Occupied" column in the tables. Is <br>
<br>
<br>
<br>
that information helpful or distracting or misleading?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Thanks, ... Peter E.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
-- <br>
<br>
<br>
<br>
Message composed and transmitted by software designed to avoid the <br>
<br>
<br>
<br>
need, overhead and vulnerability of antivirus software.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
123456789 123456789 123456789 123456789 123456789 123456789 123456789<br>
<br>
<br>
<br>
Tel: +1 360 639 0202 <br>
<br>
<br>
<br>
<a href="http://easthope.ca/Peter.html" rel="noreferrer" target="_blank">http://easthope.ca/Peter.html</a> Bcc: peter at easthope. ca<br>
<br>
<br>
<br>
--<br>
<br>
<br>
<br>
<a href="mailto:Oberon@lists.inf.ethz.ch">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<br>
<br>
<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer" target="_blank">https://lists.inf.ethz.ch/<wbr>mailman/listinfo/oberon</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
<a href="mailto:Oberon@lists.inf.ethz.ch">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer" target="_blank">https://lists.inf.ethz.ch/<wbr>mailman/listinfo/oberon</a><br>
</div></div></blockquote></div><br></div>