Re: parentNode

keshlam@us.ibm.com writes:

> I think I second Steve on this one. Nothing wrong with a null parent
> pointer; it's easier for code to deal with that than to deal with an
> implicit non-null.

There's actually a good reason to _require_ null as the parent of an orphan
node, and that is so that one can reliably determine whether a node is an
orphan (and therefore safe to insert into a tree without cloning).

It would be sufficient, though, to specify that orphan nodes have an
unambiguously-determined value for their parent, since in some languages
it's better to have an actual object as the parent than a null.

Another possibility would be to throw an exception when trying to obtain the
parent of an orphan node, but this would be less efficient and lead to
clumsier code.  Far better to simply require orphan nodes to have null as
their parent. 

The third possibility is to add an "isOrphan()" method.  This may be best,
since it avoids even looking at the parent, which might (according to the
present spec) have to create a fragment.

-- 
 Stephen R. Savitzky   Chief Software Scientist, Ricoh Silicon Valley, Inc., 
<steve@rsv.ricoh.com>                            California Research Center
 voice: 650.496.5710   fax: 650.854.8740    URL: http://rsv.ricoh.com/~steve/
  home: <steve@starport.com> URL: http://www.starport.com/people/steve/

Received on Tuesday, 28 July 1998 12:33:18 UTC