martin@mwtech.UUCP (Martin Weitzel) (06/15/90)
In article <5344.267212F6@puddle.fidonet.org> cspw.quagga@p0.f4.n494.z5.fidonet.org (cspw quagga) writes: > > >>In article <1631@dinl.mmc.UUCP> noren@dinl.UUCP (Charles Noren) writes: >>> C Advantage list: >>> 5. Array subscripts in C must start with zero, which for >>> some is counter intuitive >> > >IMHO, our experience with flexible lower bounds has been appalling, and >not a very useful programming feature. [refer to above article for deleted lines] Can anybody really argue against that "some" would find something counter intuitive :-). My experience - after using C for years of course - is: Everything else is counter intuitive :-), zero origin is best. I would recommend to read the respective sections in Andrew Koenigs book "C Traps and Pitfalls" for a good treatment of the "zero-origin" and "asymmetric array bounds" topic. My experience with C has lead me to similar conclusions: If the lower array bound is zero, the chance for "off by one"-errors can be reduced with the smallest set of coding style rules. Well, "off by one"-errors will be made as long as people write programs, and just two days ago I've found one more in an example program in the curses chapter of the AT&Ts "System V Programmers Guide". The nice thing with this error is that the author gives an explicit rationale for subtracting one; but obviously he never tried his formular with a simple example, otherwise he would have seen that it is simply wrong. -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83