As part of the clean-one-node world I am going to clean up Leo's
iterators using Python generators. As always, the old names will
remain for compatibility with scripts and plugins.

1.  Position generators are the base of the scheme.  For example, here
is a partially tested rewrite of c.allNodes_iter, called, much more
properly, allPositions().  These functions will eventually become
generators of the commands and positions classes, so the 'c' arg will
turn into 'self':

def allPositions(c):
    this,next = None,c.rootPosition()
    while next:
        this = next
        next = this.threadNext()
        yield this
    raise StopIteration

2. Generators returning (unified)nodes simply use the corresponding
position generators.  Thus, all such generators must be members of the
commands or position class, *not* the vnode class.

def allNodes(c):
    for p in allPositions(c):
        yield p.v
    raise StopIteration

This scheme will eliminate all lambda bindings in the iterators,
something that must be done for Python 3k. More importantly, the new
code is substantially simpler than the old.

The new scheme will retain the "unique" iterators that return
positions p such that p.v appears only once.  These will use the
moveToThreadNextUnique pretty much unchanged, except we can dispense
with the "unique" lambda binding.

Edward

P.S.  I have, once again, to thank the late great Bernhard Mulder for
this work. It was he who wanted to use generators years ago.  I do
wish he were here to see it.

EKR
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to