Assignment in test: OK?

Clarence Dold dold at mitisft.Convergent.COM
Wed Sep 12 07:00:06 AEST 1990


in article <1990Sep11.003102.9271 at virtech.uucp>, cpcahil at virtech.uucp (Conor P. Cahill) says:

>>>     if (foo = 0)

> This is a BIG mistake because of any and all of the following:

> 	2. someone else will have to determin if you might
> 	   have made a typo

> The fact that it is legal C doesn't really matter here.  That kind of
> coding just makes maintenance harder.

I saw this in some code posted to the net awhile ago:

   if (foo = 0)		/* Really an assignment */

Which is at least intelligible, and (possibly) rules out item 2 above.
I still don't think it is good coding practice.

As someone who makes a living reading other people's code, I wish more
people would not try to outwit the compilers, and just buy a better 
compiler.

-- 
---
Clarence A Dold - dold at tsmiti.Convergent.COM            (408) 435-5293
               ...pyramid!ctnews!tsmiti!dold        FAX (408) 435-3105
               P.O.Box 6685, San Jose, CA 95150-6685         MS#10-007



More information about the Comp.lang.c mailing list