On Aug 3, 8:19 am, "Edward K. Ream" <[email protected]> wrote:
> # Compute the first node and the node after theIter completes.
> for p in theIter():
> first = p.copy()
> after = p.nodeAfterTree()
> break
> else: return g.trace('oops: theIter fails')
This is wrong, and we have a problem. We need to know the node
*after* theIter completes. But how to do this? We can't use theIter
directly! That is, we can *not* do the following::
first,after = None,None
for p in theIter():
if not first: first = p.copy()
last = p.copy()
last = last.threadNext()
Once again, this creates a (copy of a) position for every position
returned by theIter! And yes, the calls to p.copy are both essential.
The theIter param could be a *name*, the code can compute the ending
point for each named iter. Or the code could make tests like theIter
== c.all_position, theIter == p.subtree etc. Either of these options
would limit theIter to a fixed set of iterators.
Another option would be to have the caller specify the 'after' node.
This is more general, but more error prone.
Edward
P.S. As I look at the code, I realize that what I have been calling
"iterators" are now Python generators. But this changes nothing.
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.