Re: NodeList (Re: CSS::SAC)

>I'm gunning for (to a certain degree at first, more later) but so is
>performance. Live NodeLists just don't work with the latter

The solution taken in the Java world, and as far as I can tell in the
JavaScript and C++ worlds, is that this is an accepted tradeoff. Nobody is
required to use NodeList; if they don't like its performance they can walk
the tree directly or use the DOM Level 2 Traversal feature instead.

There are some fairly straightforward implementation tricks which keep the
overhead minimal when NodeLists are not actively in use, ranging from a
flag which isn't set until the first NodeList is created to not rebuilding
NodeLists until they user actually accesses them. There are a number of
open-source fully-compliant DOMs in other languages; you might want to look
at how they've handled NodeList before you conclude that it's
unsupportable.

I freely admit that I've never liked NodeLists. I initially had  exactly
the same concerns you've voiced. But I  discovered that I could, in fact,
write a reasonable implementation which performs well in the most common
cases and performs correctly in the rest without an unacceptable amount of
impact on code size or performance of the rest of the DOM. NodeList will
always have some cases where its performance is horrendous and behavior is
unintuitive, but DOM users know that and write around it.

I really would recommend that Perl implementations adopt these strategies
and attempt full compliance with the DOM spec. Especially if you might be
interested in some day convincing the W3C to officially recognize a
standard Perl binding for the DOM.

______________________________________
Joe Kesselman  / IBM Research

Received on Wednesday, 21 March 2001 11:20:30 UTC