On 5/22/2013 9:30 AM, Edward K. Ream wrote:
Here is the first draft of a tutorial for positions. It wasn't easy. All comments welcome.

A **position** object represents a specific node in a Leo outline.

Equivalently, a position represents the state of a Leo generator, that is,
a specific node during a traversal of a Leo outline.

Because of clones, a node may appear arbitrarily many times in an outline,
so a node may appear at arbitrarily many positions in the outline.

For any position p, **p.v** is the vnode at position p.

A node's vnode never changes, regardless of where the node appears in the
outline, and regardless of whether the node is cloned or not.

**Positions become invalid when the outline changes.**

You may save and and use positions *provided* the outline remains unchanged.

Leo's generators deliver positions, one after each other, using a *single*
(ever-changing) position. As a result, scripts must use p.copy() to create
lists of positions. For example,

    aList = [p.copy() for p in c.rootPosition().subtree()]

Edward

P.S.  I considered using an example outline containing clones,
but I'm not sure that adds enough to be worth including in a precis.

EKR

That last bit about p.copy() just enlightened me all over the place...

This is a good draft.  I like it as is.

-->Jake

--
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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to