RE: An observation about "live" NodeLists

>In Java, at least, this is a serious issue, because the vagaries
>of GC make it impossible to tell particularly early whether or
>not a NodeList is in use.

In fact, I looked at such an implementation, and quickly decided Java
wasn't well suited to it and/or vice versa. Since Java's GC-based, making
the Nodes aware of the NodeLists means the NodeList objects have to persist
as long as the Nodes they're based on do; there's no architected way to
tell the DOM that they're no longer needed.

You could limit this to some extent by making them pseudo-singletons, such
that each Node has at most one NodeList of each type active; since they
can't be modified directly by the user, that's safe even if the same query
has been issued several times. But you still with up with each node
potentially having a NodeList for every Tag name which has ever been
searched for (whether or not that tag actually exists anywhere in the
document). As Miles says, maintaining that can represent a lot of space and
computation overhead in order to optimize an operation that may never be
issued.

Mostly, what this proves is that there are many ways of building a
complying DOM, and that different implementations will be tuned for
different assumptions about what applications will want to do with them.
Think of buying a DOM as like buying a vehicle -- Arthur needs to haul
several tons of cargo, Emily needs to get there quickly, and Fred needs
something he can pick up and carry. The nice thing about a standard API is
that we can all drive each others' vehicles and reach our destination,
though we may find that the best driving technique varies from vehicle to
vehicle.

My current draft of the essay gives three different working solutions to
Steve's delete-all-instances problem... and comes to the conclusion that
which one is best depends on the characteristics of the particular DOM
they're run against.
______________________________________
Joe Kesselman  / IBM Research
Unless stated otherwise, all opinions are solely those of the author.

Received on Monday, 19 October 1998 17:48:59 UTC