Article View: comp.std.c++
Article #2550Re: New treatment of 'for (int i ...'
From: Phil Richards
Date: Tue, 14 Nov 1995 13:51
Date: Tue, 14 Nov 1995 13:51
41 lines
1773 bytes
1773 bytes
In <mferrel-0911951136400001@sa-1en64.sonoma.edu>,
Mike Ferrel <mferrel@zippy.sonoma.edu> writes:
> In article <sjcDHqMKM.MBG@netcom.com>, sjc@netcom.com (Steven Correll)
> wrote:
> > Must portable programs do this?
> > for (unsigned i0 = 0; ...; ...)
> > ...
> > for (unsigned i1 = 0; ...; ...)
> > ...
> How about
> unsigned i;
> for(i = 0; ...; ...)
> ...
> for(i = 0; ...; ...)
> ...
How about:
{
unsigned i;
for (i = 0; ...; ...)
...
}
{
unsigned i;
for (i = 0; ...; ...)
...
}
Gives the advantages of the new style scoping barring an annoying
extra level of indentation and is portable between compilers. That's
what I've used until now -- the old style led to too many annoying
problems when rearranging code.
Phil
--
not speaking for ICL
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<pgr.122211.14Nov95@sst.icl.co.uk>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<47itjt$65m@lhc.nlm.nih.gov> <sjcDHqMKM.MBG@netcom.com> <mferrel-0911951136400001@sa-1en64.sonoma.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 14 Nov 95 13:51:43 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ From: pgr@sst.icl.co.uk (Phil Richards) Subject: Re: New treatment of 'for (int i ...' Message-ID: <pgr.122211.14Nov95@sst.icl.co.uk> Content-Type: text Reply-To: pgr@sst.icl.co.uk (Phil Richards) Organization: ICL, Bracknell, UK. References: <47itjt$65m@lhc.nlm.nih.gov> <sjcDHqMKM.MBG@netcom.com> <mferrel-0911951136400001@sa-1en64.sonoma.edu> X-Original-Date: Tue, 14 Nov 1995 12:31:47 GMT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMKifJOEDnX0m9pzZAQGBVwF/aOm0MrGYj4dTHTpDv2THF28qgGsGwb9P I5d43ZTBfTAF2K63HrckU9LAujVGabMd =GJEv