Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!bu.edu!mirror!rayssd!jarsun1!drd!apctrc!zmls04 From: zmls04@trc.amoco.com (Martin L. Smith) Newsgroups: comp.lang.c++ Subject: Re: C++ coding standards (Comment needed) Message-ID: Date: 13 Aug 90 14:16:20 GMT References: <2161@runxtsa.runx.oz.au> Sender: news@trc.amoco.com Organization: Amoco Production Company, Tulsa Research Center Lines: 25 In-reply-to: edward@runxtsa.runx.oz.au's message of 12 Aug 90 02:46:29 GMT We have just started to move from C to C++ and the declare-at-usage style still looks a little strange. I've noticed a tendency in my own code to declare throwaway variables (the index in a loop, say) when they are used but to group more significant ones in declaration chunks, which are not always at the start of a function block. I've noticed at least two drawbacks in this style: 1 - It's cowardly and has no really clear principles. 2 - Declaring loop indices at point of use leads to some problems in my case, at least, because I tend to reuse i, j, etc, and C++ doesn't like repeated declarations (at least in the first clause of a for-loop). The second for loop that uses 'i', for example, should not declare it. If I later delete the first loop then I have to remember to add the declaration to the new first loop (the old second loop, that is [are you still there?]) or I get a compile error. This symptom strikes me as an indication that this style is not the best we could do. Anyhow, I too would really like to read more discussion on this issue. -- Martin L. Smith Amoco Research Center P.O. Box 3385 zmls04@trc.amoco.com Tulsa, OK 74102 [zmls04@sc.msc.umn.edu] 918-660-4065