Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site l5.uucp
Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!sun!l5!laura
From: laura@l5.uucp (Laura Creighton)
Newsgroups: net.lang.c
Subject: constructs like if (NULL == (fp = fopen("foo", "r")))
Message-ID: <173@l5.uucp>
Date: Wed, 2-Oct-85 16:51:19 EDT
Article-I.D.: l5.173
Posted: Wed Oct  2 16:51:19 1985
Date-Received: Sat, 5-Oct-85 08:12:02 EDT
References: <1702@brl-tgr.ARPA> <1941@reed.UUCP>
Reply-To: laura@l5.UUCP (Laura Creighton)
Organization: Ell-Five [Consultants], San Francisco
Lines: 46

I took a look at that and thought: ``Wow! Does that *ever* offend
my aesthetic sense! Ugly, ugly, ugly...''.  Now I have this cherished
belief that my aethetic sense is inherantly rational; that is to say
that if I think something is ugly then I have some good reason to
say so even if I can't put my finger on it at the time.  And when I
get a strong reaction as I got to that construct, I try to take the time
to find out what that reason is.  But I digress...

The reason I found out that I hate this style is because I see a strong
conection between statements like:

	if (fp = fopen("foo", "r")) == NULL)

and ones like

	fp = NULL;

that is to say, mentally I have a strong binding between ``this is a
known value that I want to test things against'' and ``this is a known
value that I want to assign my variable to''.  So, when you invert this
you shoot my conceptual model all to hell.  To rectify it I would have
to start writing things like:

	NULL = fp;
	sizeof(string) + 1 = arraylength

and this means swapping lvalues with rvalues -- the language isn't C.

In short, I couldn't use that style because it conflicts with my internal
model of what a program in any block-structured language should look like.
I think that you would be better off to run all your C programs through a
script that prints all instances of ``if(condition)'' where ``condition''
contains a single equals (not precedded by a !, obviously).  The times
I have meant to use this construct (ie it wasn't a bug) I can count on
the fingers of my hands.  But, then again, the times I have done this
wrong I can count on the fingers of my hands as well. My favourite
typo which I can never see is to substitute ``>'' for ``<'' or vice-versa.


 

	
-- 
Laura Creighton		(note new address!)
sun!l5!laura		(that is ell-five, not fifteen)
l5!laura@lll-crg.arpa