Re: Level 2 iterators

John Cowan wrote:
> I don't think you can, if the black box is allowed to mutate the
> tree in arbitrary ways.  In particular, a mutator that uses the
> rule "Remove the current node and append it to its current parent"
> will cause any reasonable iterator to loop, or at best fail.

What my black box do is act on the current node by either removing it,
replacing it or just changing it. It's part of the OpenXML processing
API. It is implemented as two separate operation, one iterating the
document tree the other one changing the current node.

If a node is replaced with a different node or moved elsewhere, it will
be iterated twice, and that's fine. If the node becomes the last child,
it can do so only once. What you suggest is an extreme case that will
break it, but anything is breakable if you try hard enough.

I came up with this example to illustrate that a locking mechanism is no
solution. Before an implementation can become concurrent by adding
locking it should first be tested to work reasonably well in a single
threaded application. If you try hard enough you will find that many
algorithms break when they are put to this test, even when only one
thread is involved in the process.

Arkin

PS
Just realized you're the guy behind XCatalog and DOMParser. I would like
to introduce myself as the guy behind OpenXML (www.openxml.org) and
would like to know if: a) you have plans for proposing XCatalog as a W3C
draft, and b) any ideas for an XCatalog based API?


> 
> --
> John Cowan      http://www.ccil.org/~cowan              cowan@ccil.org
>         You tollerday donsk?  N.  You tolkatiff scowegian?  Nn.
>         You spigotty anglease?  Nnn.  You phonio saxo?  Nnnn.
>                 Clear all so!  'Tis a Jute.... (Finnegans Wake 16.5)

Received on Friday, 5 March 1999 16:27:18 UTC