Hi,
> The most radical version of this idea would be to change from this
> representation:
> {'_tag' => 'foo',
> '_parent' => some_node,
> '_content' => [node2, node3],
> 'id' = 'stuff',
> }
> to something like:
> [
> 'foo', # 0: always for the tag name
> some_node, # 1: always for the parent node
> 5 # 2: index of the start of contents
> 'id', # 3 to $self->[2]-1: attribute keys and values
> 'stuff',
> node2, # $self->[2] - $#$self : contents (children)
> node3,
> ]
Wouldn't something like
[ 'tag',
parent_node,
[node2, node3, ...], # content
'attr1',
'value1',
'attr2',
'value2'
]
make more sense?
The only disadvantage I see is the memory penalty for an additional array.
The pros:
- content() could work as it used to
- there is no need to shift the whole content, if an attribute is added.
- content access should be slightly faster
Another possibility:
['tag',
parent_node,
['attr1','value1','attr2','value2'], # or {'attr1'=>'value1','attr2'=>'value2'}
node2,
node3,
...
]
Pro: The array or hash for attributes is only needed, when the tag has attributes.
(That's only a minority of tags compared the tags with content.)
Con: content() wouldn't work as it used to.
Ciao, Claus [EMAIL PROTECTED]