This branch cleans up some ugly behind-the-scenes machinery.
*tl;dr:* The clean branch will merge into master tomorrow. Nothing would be
gained by delay.
*Replace c.nullPosition() with None*
- Leo's core code now uses None instead of c.nullPosition(). c.p can be
None during startup, which necessitated a few new guards. As a result, the
following are all valid tests:
if not p: # Correct, pre-Leo 5.5.
if not p.v: # Correct, pre-Leo 5.5
if p is not None # Correct, Leo 5.5 and later.
if p is None: # Correct, Leo 5.5 and later.
Now that these tests "just work", there is no need to document them in the
scripting tutorial.
*All generators yield copies of positions*
As of today, all generators works as expected. Scripts can capture
positions as follows:
aList = list(c.any_generator())
aList = list(p.any_generator())
There is no need to discuss the previously-required patterns:
aList = [z.copy() for z in c.any_generator()]
aList = [z.copy() for z in p.any_generator()]
*Testing*
Replacing c.nullPosition() with None was remarkably easy. I just had it
return None instead of an "empty" position. I then fixed a few crashers
during startup by adding a few guard. I don't expect serious problems to
remain. After startup, we expect c.p to be well defined.
Indeed, using None is much more Pythonic than using a dummy position.
Failures are no longer hidden. In every case a simple guard suffices.
*Summary*
The clean branch is an important improvement to Leo's code base. The branch
will be merged into master tomorrow. These changes also simplify Leo's
public API. Fewer oddities need to be documented.
I would not have had the nerve to make the changes I made without cff. This
command confirmed that what I thought I knew about the code was correct.
Edward
--
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 https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.