It occurred to me that a lot of times there is indendation with looping with no intervening code, other than the for loops themselves. For example: for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { Instruction &Inst = *I; ..... It would seem that this would better to be just: for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { Instruction &Inst = *I; .... Even if there was some code after the first "for", it could be indented but still the following "for" could appear as is. For example: for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { xyz(); for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { Instruction &Inst = *I; .... } }
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of reed kotler > Subject: [LLVMdev] reducing indentation> It would seem that this would better to be just:> for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) > for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { > Instruction &Inst = *I; > ....Just personal opinion, but that's bloody horrible - an accident waiting to happen. It would be far too easy to misinterpret the second for as not being the target of some outer construct, and erroneously add code between the two for statements. What would be worse is when someone decides to add a comment preceding the second for statement, making it even easier to commit a blunder. (This is not idle speculation - I had to fix a Linux kernel bug caused by this exact scenario.)> Even if there was some code after the first "for", it could be indented > but still the following "for" could appear as is.> For example:> for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { > xyz(); > for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { > Instruction &Inst = *I; > .... > } > }Two closing braces in the same column? You can't be serious. That's as bad as the convoluted syntax for anonymous internal classes in Java. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
On Thu, May 9, 2013 at 2:30 PM, reed kotler <rkotler at mips.com> wrote:> It occurred to me that a lot of times there is indendation with looping with > no intervening code, other than the for loops themselves. > > For example: > > for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) > for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { > Instruction &Inst = *I; > ..... > > > It would seem that this would better to be just:Makes it harder to keep track of how many levels of indentation/bracing are involved. Generally if anyone finds they're running out of horizontal real estate due to indentation, that should be a sign they might want to break out some portions of the code into smaller functions or otherwise restructure the code.> > for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) > for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { > Instruction &Inst = *I; > .... > > > Even if there was some code after the first "for", it could be indented but > still > the following "for" could appear as is. > > For example: > > for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { > xyz(); > for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { > Instruction &Inst = *I; > .... > } > } > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev