Re: [Element Traversal LC] access to element by index

On Apr 2, 2008, at 12:44, Jonas Sicking wrote:
>> And to what end? To use indexing instead of list-style iteration.
>
> Exactly. Something that I would imagine is quite commonly done. Note  
> that we're not just talking iterating over a full DOM tree, we're  
> also talking about navigating around in a DOM tree from one known  
> specific node to another.


It seems to me that allowing indexed access to children creates a  
similar kind of problem that allowing indexed access to strings by  
UTF-16 code unit has created. Allowing app code to index into platform  
structures that are most commonly forward-iterated seems like an anti- 
pattern in terms of what implementation constraints are placed if the  
impression that the app developer gets is that indexing has the  
performance properties of array access and that it is OK to write app  
code with that assumption.

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/

Received on Wednesday, 2 April 2008 10:01:55 UTC