Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 exptools; site ihlts.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ihlts!lied
From: lied@ihlts.UUCP (Bob Lied)
Newsgroups: net.lang.c
Subject: Re: assignments in if statements
Message-ID: <645@ihlts.UUCP>
Date: Fri, 28-Jun-85 20:21:49 EDT
Article-I.D.: ihlts.645
Posted: Fri Jun 28 20:21:49 1985
Date-Received: Sat, 29-Jun-85 04:40:06 EDT
References: <474@crystal.UUCP> <397@umcp-cs.UUCP> <721@wlcrjs.UUCP> <496@umcp-cs.UUCP>
Distribution: net
Organization: AT&T Bell Laboratories
Lines: 18

Regarding the debate about nesting assignments in if statements, such as

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

I prefer to make the assignment separate for the simple reason that
it gives me a place to set a breakpoint and test an alternate value
before the program decides what path to take.  It's not quite so
useful in 'if' statements, but before a switch it comes in very handy.
For example, 

	c = getchar();
	switch ( c )			switch ( c = getchar() )

In the example on the left, I can examine c before the program goes on,
and I can change it if I need to test a strange case; on the right,
I have to depend on the input data.

	Bob Lied	ihnp4!ihlts!lied