Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 01 Nov 2011 05:34:37 -0500 Message-ID: <4EAFCB40.18B5@mindspring.com> Date: Tue, 01 Nov 2011 05:34:40 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: the loop control References: <20111029175230.259@kylheku.com> <878vo0kgzj.fsf@bazspaz.fatphil.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 43 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.219.66 X-Trace: sv3-rKOms+LsxZ9/jYK9raLWwtdEXKZ36yo+M5qgAB4f8nQtecMxrvzil0c2ggKr5bNpdlD+KR5AZ5ef5MD!+q1cF4ldmNMyKqp1DujzXcfOCeDijBpeaZbKrxYO3l4SRByeDhjQ7S4VNOGl8jXrpKmlTpRGTwUu!m74+N4lUPg== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2271 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:12435 Ike Naar wrote: > In the simpler example that you showed (only one sweep > across the point array), one can make a tradeoff between two > desirable objectives: > a) keeping the parameters constant > b) minimizing the number of local variables > > I think a) vs. b) is a honest tradeoff, > and not a dumb vs. smart question. My preference is to alter the value of parameters at every given oportunity. void strcpy(char *s1, const char *s2) { while ((*s1++ = *s2++) != '\0') { ; } } If it turns out that I need the original value of a parameter throughout the code, then my preference is to do that by initializing a const qualified local variable with the original value of the parameter. That's very easy to do, even as an alteration to code which was originally written without preserving the parameter value. char *strcpy(char *s1, const char *s2) { char *const p1 = s1; while ((*s1++ = *s2++) != '\0') { ; } return p1; } -- pete