Al Chou wrote:
My personal preference would originally have been to use 1-based indexing (actually, I really prefer Fortran's ability to let the user define the lower bound index value in each array dimension if they so choose, even though that facility is not that often used), but that was based on my assumption that commons-math is a library for enabling people who know some math to more easily do math in Java. However, the few use cases we've heard about seem to be split between that kind of user and Java programmers who have some need for math capabilities. The former class of user would more likely want/expect 1-based indexing, the latter would expect 0-based indexing. Quoting from our own home page:
"Guiding principles:
1. Real-world application use cases will determine development priority. ... 4. In situations where multiple standard algorithms exist, a Strategy pattern will be used to support multiple implementations."
Unfortunately, nowhere in our charter do I know of a statement that would help us decide the priority between the two classes of users I described above (I would be happy if someone pointed out some passage of our charter that I don't know about that would resolve this decision).
I think ideally we would provide facilities to handle both 0- and 1-based indexing (and even arbitrary lower-bound-based indexing, given that I'm pipe-dreaming here).
The _Numerical Recipes_ solution to this problem is to stick to 1-based indexing throughout, as all algorithms are described in standard mathematical notation where the first index in each dimension is 1 (probably also because it made for easier [possibly at least partially automated] translation from the original 1-based Fortran source code into other languages). For 0-based languages (viz., C and presumably C++) they provided array data types that automatically translated between the mathematical 1-based notation and the underlying 0-based array data structure, at the expense of having one extra element in each dimension of each array, I believe. Perhaps we could do something similar and even provide a user setting that would choose between 0-based and 1-based behavior -- probably a global setting, to prevent the kind of confusion that would result from mixing the two representations unintentionally.
Al
At first this sounds like a concession to both sides of the issue, But, my fear is that this will introduce more complexity and confuse the user. I would say one or the other, not both. I think theres too much ridiculous partisanship when it comes to subjects like "whats the best language". Its amazing what people with fixate on and defend as important (myself included). Thats why I suggest indexing in that of the implementation language. If I were working with Fortran, I'd argue to use 1 <= x < n.
I'm sure it doesn't matter very much either way...
-Mark
-- Mark Diggory Software Developer Harvard MIT Data Center http://www.hmdc.harvard.edu
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
