Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is actually symmetrical. When you use 0-based indexing, you can't count down with a simple loop: you need to either extend your index type to include an invalid -1 or apply the infamous evaluate-then-decrement semantic. In practice, this means people often index with a signed integer, which is absurd.

And lest you think that counting down is unnatural—there are quite a few advantages in comparing to zero on every iteration instead of a computed upper bound, like that you can often roll the condition check in with the decrement instead of having to do a separate comparison.



I'd also argue that counting down is more common than having a list with UINT_MAX elements.


Ah that's a very good point.




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

Search: