Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site aoa.UUCP
Path: utzoo!linus!philabs!cmcl2!seismo!bbnccv!bbncca!aoa!mbr
From: mbr@aoa.UUCP (Mark Rosenthal)
Newsgroups: net.lang.c
Subject: Suggestion to enhance code readability
Message-ID: <255@aoa.UUCP>
Date: Thu, 22-Aug-85 19:21:32 EDT
Article-I.D.: aoa.255
Posted: Thu Aug 22 19:21:32 1985
Date-Received: Sun, 25-Aug-85 10:42:18 EDT
References: <11457@brl-tgr.ARPA> <68@ucbcad.UUCP> <1693@reed.UUCP>
Distribution: net
Organization: Adaptive Optics Assoc., Cambridge, Mass. USA
Lines: 30

Although our site has been receiving articles for the past few months,
articles posted to the net have not been getting distributed until recently.
The following is a reposting of an article I sent out quite some time ago.
I believe it never made it to the net at large.  Apologies if you have seen
this before.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Alexis Dimitriadis (alexis @ reed) writes:

>   Expressions like "while (var++) ;" introduce problems that take
> (bitter) experience before they can be handily detected, even if the
> reader is familiar with the semantics of the expression.  That is the
> real reason it takes a seasoned C programmer to debug seasoned C code.

Since every simple C statement ends with a ";", it is easy to misread
the ";" in the above as a terminator for the while statement, rather
than a terminator for a null statement controlled by the while.  Placing
the ";" on the same line as the while makes this misinterpretation very
likely.  That is why I came up with the following (equivalent) construction,
which I have been using for several years.  I believe it enhances readability.
But then, I have weird tastes.

        while (var++)
            { }


-- 

	Mark of the Valley of Roses
	...!{decvax,linus,ima,ihnp4}!bbncca!aoa!mbr