[XML-SIG] Ugh! Why are DOM access methods spelled with a leading '_'?

Paul Prescod paul@prescod.net
Tue, 27 Jun 2000 12:29:35 -0700


Jim Fulton wrote:
> 
> ...
>
> The abstraction of attribute access to allow computation *is* a Python
> idiom, but so is use of accessor functions.  Avoidance of circular references
> is *certainly* a common Python design practice.  There are techniques for
> implementing the DOM API that avoid circular references that require
> compting some DOM attributes. Requiring that DOM attributes be published
> as Python attributes makes this harder.

Avoiding circular references in a DOM environment is hard and almost
always has a negative impact on performance. If your implementors are
"up to" doing all of this proxy magic, using attribute accessor
functions will be comparitavely a snap.

Or if *you* are implementing the proxy for them, then you can implement
the attribute accessor functions for them.

Note also that the Python bug of having trouble with circular references
is scheduled to be 
"experimentally" fixed in 1.6 and totally fixed in 1.7. I am relucatant
to design around it. If we put our heads together, the efficiency hit of
accessor functions could also be solved in the 1.7 timeline (by making
them a first-class language feature).
 
> I question the value of list consensus without follow through. I, as a DOM
> implementor have no way of knowing what the list consensus was unless I
> happened to be paying attention at the time, which I wasn't. If there was
> consensus, then it should be published.

You are asking for a more formal process than is used in the Python
world. I don't think that there isn't even formal documentation for the
"file" interface used in hundreds of places. comp.lang.python and /lib
are the documentation. In open source land, "go look at the code" is a
vald answer (though sometimes suboptimal).

> When I asked about the API a few days ago, there didn't seem to me
> to be much consensus about what the Python DOM API actually is.

I believe that there was consensus among people who have implemented
DOMs. I expressed the opinion that I wasn't entirely happy with the
leading underscore thing, but that's what I implemented in my DOM
anyhow.

As far as I know, the three Python DOMs all allowed the use of either
methods or direct attribute access.

-- 
 Paul Prescod - Not encumbered by corporate consensus
When George Bush entered office, a Washington Post-ABC News poll found
that 62 percent of Americans "would be willing to give up a few of the
freedoms we have" for the war effort. They have gotten their wish.
	- "This is your bill of rights...on drugs", Harpers, Dec. 1999