On Fri, 09 Dec 2005 08:15:14 +0000, Zeljko Vrba wrote: > On 2005-12-08, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> >> Making a mistake in indentation level is precisely analogous to leaving >> out markers in other languages. If your editor is smart enough, and the >> > But look at the following example: > > if a: > some_code1 > if b: > some_code2 > > If I accidentaly delete if b:, then some_code2 gets under the if a: which is > not intended. With braces (or other delimiters): > > if(a) { > some_code1; > } > if(b) { > some_code2; > } > > if I delete if(b) I get a syntax error about unmatched braces.
Not unless you also delete the opening brace on the same line, surely? Okay, you've deleted the line and you get a syntax error. But not if you accidentally deleted the previous brace as well, or if there was an earlier unmatched brace somewhere earlier in your code. We could play this game all day -- you find some error or typo where redundant braces will save the day, and I'll find another error where they won't. In the meantime, you're spending more time thinking about braces plus indentation than I am thinking about just indentation. And I bet that you've made more mistakes where you got the indentation right but the braces wrong, even with a smart editor, than I've accidentally deleted code in a way that the indentation levels just happen to wrongly match up. > IMO, the "right" > way to handle braces in C is always to include them, even when they are not > technically obligatory. I code like that for a long time and it has saved me > a lot of headache. Sure, and that's good advice for C, but that's because C is labouring under the disadvantage that indentation is not meaningful to the compiler, but is meaningful to the human programmer. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list