W3C home > Mailing lists > Public > public-webapi@w3.org > April 2008

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

From: Henri Sivonen <hsivonen@iki.fi>
Date: Wed, 2 Apr 2008 13:01:07 +0300
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "Web APIs WG (public)" <public-webapi@w3.org>
Message-Id: <F9F962D6-B882-418F-BD38-008AD4870540@iki.fi>
To: Jonas Sicking <jonas@sicking.cc>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 2 April 2008 10:01:55 GMT