Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!appserv!sun!amdcad!dgcad!dg-rtp!gamecock!hagins From: hagins@gamecock.rtp.dg.com (Jody Hagins) Newsgroups: comp.lang.c Subject: Re: One more point regarding = and == (more flamage) Message-ID: <1991Mar22.195200.11719@dg-rtp.dg.com> Date: 22 Mar 91 19:52:00 GMT References: <13603@helios.TAMU.EDU> <3182@inews.intel.com> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Reply-To: hagins@gamecock.rtp.dg.com (Jody Hagins) Organization: Data General Corporation, Research Triangle Park, NC Lines: 55 In article <3182@inews.intel.com>, bhoughto@pima.intel.com (Blair P. Houghton) writes: |> In article <13603@helios.TAMU.EDU> byron@archone.tamu.edu (Byron Rakitzis) writes: |> >It's this: There is no way when you see the code-fragment |> >a) while (*foo++ = *bar++) |> >to tell whether a copy of data in strcpy fashion is intended, or whether |> >this should have been a strcmp-like loop: |> > while (*foo++ == *bar++) |> >the first instance is rendered UNAMBIGUOUS by the addition: |> >b) while ((*foo++ = *bar++) != 0) |> |> Or by the additions: |> |> /* copy bytes till end of string */ |> while (*foo++ = *bar++) |> |> /* compare bytes till there's a difference */ |> while (*foo++ == *bar++) |> |> /* mommy: please hold my hand */ |> while ((*foo++ = *bar++) != 0) |> |> Basically, if you're worth the meager pittance they direct-deposit |> into your debt with the Company Store, the comments will have |> existed long before you wrote the code. Put those in, and make |> them accurate, and it doesn't matter how much the code obfuscates. |> |> It's called top-down design, and involves _thinking_ before |> you start making mistakes. You know, I used to think this way too, while I was still an amateur. "If you're worth the meager pittance they direct-deposit into your debt with the Company Store" then you will not leave a job half-done. You will complete it by adding to the documentation clear, unambiguous code. |> |> --Blair |> "Back to basics." |> -Jody Jody Hagins hagins@gamecock.rtp.dg.com Data General Corp. 62 Alexander Dr. RTP, N.C. 27709 (919) 248-6035 Nothing I ever say reflects the opinions of DGC.