Signed word lengths and indexes
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jun 15 09:09:56 PDT 2010
On Tue, 15 Jun 2010 11:47:34 -0400, BCS <none at anon.com> wrote:
> Hello Steven,
>
>> This is easily solved - put in a comment. I frequently put comments
>> in my code because I know I'm going to forget why I did something.
>
>
> All else being equal, code that *requiters* comments to understand is
> inferior to code that doesn't.
Code should *always* have comments. I hate reading code that doesn't have
comments, it allows you to understand what the person is thinking.
That being said, I don't think this construct requires comments, maybe a
note like 'uses underflow' or something to let the reader know the writer
was aware of the issue and did it on purpose, but a comment is not
essential to understanding the code.
*That* being said, I don't expect to use this construct often. Typically
one iterates forwards through an array, and foreach is much better suited
for iteration anyways.
>> Reading code assuming integer wrapping never occurs is a big mistake.
>> You should learn to assume wrapping is always possible.
>>
>
> You should learn to write code where I and everyone else doesn't /need/
> to assume it is possible.
Why? If you can't understand/spot overflow/underflow problems, then why
should I cater to you? It's like lowering academic testing standards for
school children so they can pass on to the next grade.
>
> (personably, I find it marginally offensive/greedy when someone's first
> proposal as to how to fix a problem if for the rest of the world to
> change and the second option is for the person to change.)
>
Why is it offensive if I expect a code reviewer to take overflow into
consideration when reviewing code? It's not some sort of snobbery, I just
expect reviewers to be competent.
-Steve
More information about the Digitalmars-d
mailing list