​​
​On Mon, Feb 9, 2015 at 6:53 AM, Edward K. Ream <[email protected]> wrote:

​> ​There is no guarantee that this scheme will work, but I have high
hopes. During testing, the new code will be enabled by a new_shadow switch
at the start of leoShadow.py.

Everything appears to work as of rev fff0a5e!  From the checkin log:

QQQ
All unit tests pass with new_shadow = True.

However, this push sets new_shadow = False so that only the adventurous
need test the code.
QQQ

​> ​
The 'replace' opcode poses a question that has been swept under the rug.
When replacing one set of lines by another, where should sentinels be
written?

​The simple code given earlier will work, but it causes a unit test to
fail.  Yes, the test itself could be changed, but the following code
intersperses changed lines as before::

​    tag,ai,aj,bi,bj = opcode
    b_lines = list(reversed(x.b[bi:bj]))
    for i in range(ai,aj):
        x.put_sentinels(i)
        if b_lines:
            x.put_plain_line(b_lines.pop())
    # Put any trailing lines.
    while b_lines:
        x.put_plain_line(b_lines.pop())

Imo, the present code is the way the update algorithm is written in The
Book.

Edward

P.S.  There was one complication.  The 'insert' code now starts with::

   x.put_sentinels(ai)

So now all opcode handlers start with a call to put_sentinels(ai), ensuring
that all sentinels get called at *least* once.

A kludge: x.put_sentinels clears x.sentinels[i] after writing it, thereby
ensuring that sentinels get written at *most* once.

You might call this Post Script a proof of the correctness of the
algorithm...

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to