On (26 May 97) Frank Masingill wrote to Cliff Rhodes...
> FM>void main()
> Frank, please use int main(void) !!!!
FM> Thanks, Cliff, I will. But WHY do the books I'm following not use
FM> it? They are some of the most promient names like Lafore, etc. I'm
FM> not implying that means they are right - just asking why you make a
FM> point of it?
Mostly because it tends to generate MUCH longer discussions than it
really merits. Most compilers will accept main returing void without
complaint. However, it's not really portable, and (more importantly)
generally ends up returning random values to the OS when it finishes.
Depending on the OS and shell in use, this tends to make the program
less useful, and with some can be extremely frustrating. Returning some
value to indicate (at minimum) sucess or failure in operation is so
trivial to add that it's hardly worth discussing doing otherwise.
As far as books go: well, you'll quickly find that many (if not most)
books set rather poor examples in some area or another. Some relatively
well known authors are notorious among better programmers for the
exceptionally poor examples they set. Herbert Schildt is probably the
best known in this regard, but is FAR from the only author guilty of
publishing example code that can't be considered exemplary.
The basic fact is that being an excellent (or even superb) technical
writer doesn't necessarily mean one is an excellent (or even fair)
coder, and vice versa. Herbert Schildt is a very good author who writes
rather poor code.
One other point worth noting is that many people who write about
programming primarily for PCs started writing about Turbo Pascal years
ago, and have simply switched to C and C++ when it became more popular.
Turbo Pascal has never made any attempt at conforming with any stardard
but itself. People who grew up with it often tend to view whatever
compiler they happen to use as the ONLY standard. The situation with C
is entirely different than with Turbo Pascal, but many authors have
never bothered quite caught onto that.
Later,
Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|