xsl-list
[Top] [All Lists]

Re: [xsl] One-based indexes in XPath

2008-05-20 09:49:09
Zero is NOT the norm for modern programming languages. It might well
be for ancient ones. It is a very poor choice, justifiable only when
trying to squeeze the last ounce of speed in a highly
numerically-intensive application.

And even there it is not justified - you simply use data structures
that have an unused first element, and so avoid the subtract one
operation in that way.

2008/5/20 Justin Johansson <procode(_at_)adam(_dot_)com(_dot_)au>:
Trusting this question is relevant to the XSL List.

Would someone please give me advice as to why "1-based" indexes are used in
XPath, such as para[1] instead of para[0] for the first para item/element?

Why does the spec for XPath (and its/XQuery operator/function library) go
against the norm for modern programming languages in which zero is the base
for array-like collections?

The reason for my question is to do with reconciling XPath and XSLT with an
implementation in Javascript in which zero is the base index for arrays.
My users may well be perplexed by having to decide whether an index number
is in XPath/XSLT-world or Javascript-world.

Thanks for comments,

Justin Johansson


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--