Path: utzoo!attcan!uunet!mailrus!ncar!groucho!steve From: steve@groucho.ucar.edu (Steve Emmerson) Newsgroups: comp.lang.c Subject: Re: a style question Message-ID: <8664@ncar.ucar.edu> Date: 1 Oct 90 19:40:23 GMT References: <12683:Oct102:57:1590@kramden.acf.nyu.edu> Sender: news@ncar.ucar.edu Organization: University Corporation for Atmospheric Research (UCAR) Lines: 16 In <12683:Oct102:57:1590@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >In article <8660@ncar.ucar.edu> steve@groucho.ucar.edu (Steve Emmerson) writes: >> # define NUM_ELEMENTS 100 >> for (x = 0; x < NUM_ELEMENTS; x++) ... >Hmmm. I'll automatically write x = NUM_ELEMENTS; while (x--) ... for >this kind of loop. On many computers it'll run noticeably faster, and I >can safely replace NUM_ELEMENTS by a function call. If the loop-body doesn't care, then I don't either. My point was the use of a symbolic name rather than a hard-coded magic cookie (i.e. NUM_ELEMENTS rather than "100"). Steve Emmerson steve@unidata.ucar.edu ...!ncar!unidata!steve