On Fri, Oct 14, 2016 at 1:42 PM, 'Terry Brown' via leo-editor <
leo-editor@googlegroups.com> wrote:

> Something that just struck me.  I want to add, to all the nodes on a
> multi-level subtree, two child nodes. Here's the code I used:
> for nd in reversed([i for i in p.subtree_iter()]):
>     nd.insertAsLastChild().h = 'src'
>     nd.insertAsLastChild().h = 'clip'
> c.redraw()
> I don't think that would have worked without the reversed(), maybe because
> positions would get corrupted (maybe not, after the recent addition of
> .copy() on iterator yields?), but definitely because it would end up
> recursively adding the pair of child nodes to themselves.

​Careful, the theory of operations for c.deletePositionsInList explains why
there is* no* order for deleting a set of nodes. See Code-->Core
classes-->@file leoCommands.py-->class
Commands-->c.deletePositionsInList--><< theory of operation >>

It's hard to remember the argument, but the conclusion is engraved in my
bean:  "the conclusion...is we must use the positions passed to
p.deletePositionsInList only as *hints* about what to do."

Reversed iterators may be safe in some situations, but usually they are
just as unsafe as forward iterators. So it seems that providing reversed
iterators is going to give people a false sense of security.


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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to