This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [using gcc book] ch10.11 Certain Changes We Don't Want to Make
- From: Russ Allbery <rra at stanford dot edu>
- To: Chris Devers <cdevers at pobox dot com>
- Cc: GCC list <gcc at gcc dot gnu dot org>
- Date: Mon, 25 Aug 2003 22:10:13 -0700
- Subject: Re: [using gcc book] ch10.11 Certain Changes We Don't Want to Make
- Organization: The Eyrie
- References: <Pine.OSX.4.56.0308252345330.12109@macdaddy.local>
Chris Devers <cdevers@pobox.com> writes:
> In section 10.11, "Certain Changes We Don't Want to Make" we have the
> following paragraph:
> * Warning when a non-void function value is ignored.
> Coming as I do from a Lisp background, I balk at the idea that
> there is something dangerous about discarding a value. There
> are functions that return values which some callers may find
> useful; it makes no sense to clutter the program with a cast
> to void whenever the value isn't useful.
> There's just a bit more axe-grinding from the MIT alum that wrote this
> than is strictly necessary, I think :)
How about this, which I think gets at the heart of the matter more
directly:
C contains many standard functions that return a value that is
occasionally useful but usually ignored by most programs. (printf is
an obvious example.) It is commonplace to call those functions
without using their return value. Warning about this practice only
leads to cluttering the program with dozens of casts to void. Such
casts are required so frequently that they become visual noise, and
writing those cats becomes so automatic that they no longer convey
useful information about the intentions of the programmer.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>