Bob La Quey wrote:
On Feb 18, 2008 4:02 PM, Andrew Lentvorski <[EMAIL PROTECTED]> wrote:
Well, part of it is the fact that most XML libraries in C and Java
eventually flip themselves inside out in order to be iterative to avoid
stack faults.
Really? Color me mildly skeptical. How deep are these
XML structures anyway? Can you give me an example?
www.slashdot.org -> view page source
So, assuming that slashdot is probably well behaved, there's your
minimum depth for site.
However, you don't want *any* site to be able to crash your application
by simply nesting elements sufficiently deeply.
Suddenly, you can't access things in a recursive fashion
and have to start doing things like callbacks, iterators, etc.
There are a_lot_ of reasons to want to access things in
other than recursive fashion. That is a main reason why
we traverse stuctures, like XML structures.
I can come up with reasons, but I think you are being kind.
I would argue that we traverse structures iteratively rather than
recursively because the languages in use to this point make iterative
easier than recursive.
Without closures/continuations, there is no way to suspend the "stack"
information from a recursive set of calls to be resumed later (C, C++,
Java, for example). When you have closures/continuations, suddenly you
get recursive solutions popping up. Witness the number of "yield"-based
XML traversal solutions in Python (yield is a weak continuation construct).
To be fair, though, lots of the junk in the SAX way of traversing XML is
to deal with the fact that XML "nodes" are polymorphic while the
implementation language is statically typed.
-a
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg