more questions about efficient C code
Eugene D. Brooks III
brooks at lll-crg.ARPA
Tue Jul 2 14:34:36 AEST 1985
> > ... Any experienced C programmer recognizes this code
> > automatically and produces it without thinking. You have problems with
> > it because you are not an experienced C programmer yet.
>
> Rubbish. "Any experienced programmer should be able to understand that"
> really means "we know it's hard to read, but...". The idea is to make
No!, it does not mean that. It means that the novice who has the complaint
about not being able to understand things like
if((fptr = fopen(filename, "r")) == NULL) {
printf(stderr, ".....", .....);
exit(1);
}
Does not yet clearly understand that in C the expression (a = b) has a value,
which is whats on the RHS of the =, that can be conviently tested!
The same goes for the novice who does not understand why lint complains that
c is not used in
foo()
{
int c;
if((c = getchar()) != '\n') {
SOME CODE
}
}
More information about the Comp.lang.c
mailing list