Re: Code Comprehension
- From: "Rob Thorpe" <robert.thorpe@xxxxxxxxxxxx>
- Date: 25 Aug 2006 01:57:46 -0700
Logan Shaw wrote:
Pascal Bourguignon wrote:
Logan Shaw <lshaw-usenet@xxxxxxxxxxxxx> writes:
Pascal Bourguignon wrote:
Yes, that still retains some C idioms, but you have to assume
some familiarity with the language. (I noticed even you did
that, because you did not eliminate the "for" loop, which is
deep in the C idiom, and replace it with a "while" loop.)
Things like the low precedence of "||" and the fact that 0 by
itself is a legal character constant aren't very complicated
and are hard to miss if you have much experience with C.
The point is that types are important to understand code, and if you
consistenly mislead the reader by using consistenly the wrong
operations for the type, you don't help readability.
It's not the wrong type. Anyone who is familiar with the basics
of C knows that '\0' and 0 are both integral values. So where
is the inconsistently? There is none. They are different
notations for basically the same thing. The only difference is
that a 0 by itself might have an integral type with a larger
range of values than the type of '\0', but since the value of
both falls in the range of all integral types in C, that doesn't
really matter.
It's a type that works, through coercion. But it does not show the
reader what the code means clearly.
Whenever I deal with characters I always write foo[n] = '\0'; it's
three more character to type sure. But it's also documentation of what
I'm doing with the variable foo, it shows that it's a string/char
operation.
.
- Follow-Ups:
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- References:
- Code Comprehension
- From: jj
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Code Comprehension
- Prev by Date: Re: Code Comprehension
- Next by Date: Re: Code Comprehension
- Previous by thread: Re: Code Comprehension
- Next by thread: Re: Code Comprehension
- Index(es):