C Review

Sohan Ramakrishna Pillai sohan at im4u.UUCP
Fri Jan 16 16:06:54 AEST 1987


In article XX, some disinformed reviewer writes:
>1.  "... 95% of all C programmers couldn't give you a good
>explanation of the term lvalue..."

	Probably true in the sense that they cannot give the definition of the
term itself. Add me to such a group till I read the manual following the
above article. But try asking any C programmer with some experience what
kind of "expressions" could be used on the left side of an assignment
statement! This sounds like the ancient joke of "Mr.X, at the ripe old
age of 40, discovered that he had been talking prose all his life".


>2.  "... Switch/case could be classified as rarely used and should be
>kept till later.

!!!

>3. "... very few C programmers know much about sizeof..."

This, and (2) make me believe that the cross-section of C programmers
the reviewer has been dealing with are not representative of all
C programmers, but just some naive C users who have just had an introduction
to the C language. While it can be shown that the use of switch/case
can be avoided, perhaps with a little loss of elegance, by means of
nested if-then-else-ifs, the sizeof operator is crucial in importance
once you come to dynamic allocation. Unless one thinks of trying to
literally add up sizes of structures, by hand. :-)

>4. "... 99%  of  all  professional C  programmers  have no idea
>what typedef is all about, couldn't care less and probably
>won't ever need it."

Typedef is again another of those things you could still write programs
without, but it can be useful sometimes. Adds elegance! My guess (from
a student perspective!) is that new Pascal->C converts "overuse" it,
while old C users "underuse" it.

>5. "... 99%  of  all  professional C  programmers  have no idea
>what the comma operator is all about, couldn't care less and
>probably won't ever need it."

This is another discardable but useful feature. Professional C programmers
had better have heard of it. I come under the category of "don't care a lot,
but no harm in it".

>6. "... Leave the comma operator altogether. An intro book is no
>place for obscure and unmaintainable tricks..."

Nothing obscure about the comma operator, unless viewed from a Pascal, or
yes, FORTRAN/COBOL/something-else perspective, and nothing unmaintainable
either, unless the suggesstions made by the reviewer take root and future
generations of C programmers do not know the comma operator. So, unless
the intro is meant for kindergarten/high-school, the comma operator
should definitely be included.

>7. "... Pointers to functions ... few C programmers understand
>them or would ever need them..."

Pointers to functions should not be thrown out of the window so easily.
They can be very useful, e.g. the generic sorting routine, as mentioned by
someone else too.

>8. "... a C programmer never needs to know what a byte is..."

In the strict sense, probably true. K&R define a byte only in terms of
sizeof in their C manual (the sizeof char = 1).  One does not need to
know the hardware's definition of a byte exactly to be able to write
good, portable C programs. But the concept of a byte as a piece of
memory required to hold a character, yes, you need to know that.


Sounds like some bureaucrat from the Pentagon did the above review! :-)

__
Sohan C. Ramakrishna-Pillai
{ihnp4, seismo}!ut-sally!im4u!sohan
sohan at im4u.UTEXAS.EDU



More information about the Comp.lang.c mailing list