Hacker News new | past | comments | ask | show | jobs | submit login

What I meant was, how useful non-zero indexing is in general. The utility of indexing by enum is clear, as you say.



I've only used it a few times but IIRC it was contiguous value ranges of grouped values (I think it was error codes coming from C code) anchored to the middle of a range. e.g. an enum which goes from 0 .. N, but values 10-30 were some specific set of logical values and I didn't care about the rest. It was nice that Ada automatically did all range checks for me and I didn't have to remember to subtract to check the correct array index.

The most common thing I've seen it for is that most arrays (and containers) in Ada are written as 1 .. N, but if you're share index information with C code, you want 0 .. N-1 indexing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: