Women in Technology

Hear us Roar



Article:
  What I Hate About Your Programming Language
Subject:   C, C++, Java, maybe others - zeroth element arrays
Date:   2003-05-14 13:15:40
From:   anonymous2
Response to: C, C++, Java, maybe others - zeroth element arrays

Because it's not always just a compile time fix. If a variable is used in the index, the 'minus one' must be done at runtime. In math intensive stuff, this can be devastating. The best thing I think is a 1-based default, and an option to revert to 0-base on specific arrays.
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • C, C++, Java, maybe others - zeroth element arrays
    2003-05-24 06:26:13  anonymous2 [View]

    With one dimensional array there is simple fix. When you have elem_t a[N], indexed from 0 to N-1, then elem_t *b = (a - 1) is indexed from 1 to N.