[Oberon] Re (2): Explaining Texts.
joerg.straube at iaeth.ch
Sat Jul 28 08:50:10 CEST 2018
Here an example:
- Texts.Text represents this string "Hi Lyall, this is a text.". The length "len" of this Text is 25, the character positions "pos" can be 0..24.
- character at position pos=0 is "H", character at position pos=8 is "," character at position pos=13 is an "s".
- if this string was stored in contiguous memory (let's call it "mem"), you could easily find these characters with a simply array access like "ch := mem[pos];"
- But the implementation uses pieces instead of one big chunk of contiguous memory. So the easy array access mentioned above is not possible anymore.
- Let's assume the above Text string is broken down in 4 pieces:
piece 1: "Hi Lyal", pce.len=7 (piece holds character pos=0..6 piece's origin org=0)
piece 2: "l, th", pce.len=5 (piece holds character pos=7..11 piece's origin org=7)
piece 3: "is is a t" pce.len=9 (piece holds character pos=12..20 piece's origin org=12)
piece 4: "ext." pce.len=4 (piece holds character pos=21..24 piece's origin org=21)
- As you can see, if you sum up the len of all pieces you get the len of the text = 25. "org" is the position in the overall text of the first character in the piece.
Instead of a simple memory access, you a) need a procedure to locate the right piece "pce" where "pos" is in, and b) locate the character in that piece, that's pos - org.
The first step a) is done by procedure "FindPiece(T, pos, org, pce)", it translates pos to pce/org.
The result of the last call to FIndPiece is stored (or you can call it cached) in "org" and "pce".
What about the following wording?
- pce: found piece of last search for character position "pos"
- org: character position of first character in "pce"
Am 28.07.18, 00:43 schrieb "oberon-bounces at lists.inf.ethz.ch im Auftrag von peter at easthope.ca" <oberon-bounces at lists.inf.ethz.ch im Auftrag von peter at easthope.ca>:
From: =?UTF-8?B?SsO2cmc=?= <joerg.straube at iaeth.ch>
Date: Thu, 26 Jul 2018 08:53:12 +0200
> BTW: the two fields "pce" and "org" are not "pointers in a translation
> cache", they are the cache.
Is this any better? (Elliminate the preposition. "translation cache" becomes
attributive to piece.)
org: Offset in characters[0,len) of translation cache piece.
Regards, ... Lyall E.
Message composed and transmitted by software designed to avoid the
need, overhead and vulnerability of antivirus software.
123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202
http://easthope.ca/Peter.html Bcc: peter at easthope. ca
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
More information about the Oberon