Possible Duplicate:
Why isn't the line count in Visual Studio zero-based?
Why isn't the top line in a source code file labelled line number 0?
i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now grep
, awk
, sed
etc all seem to number from 1, so I'm assuming it's an established convention for a good reason.
It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1!
I was just wondering if there is a good reason for this or if it's just an unfortunate historical convention.