Dangling if
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Sep 27 18:43:13 PDT 2012
So I just had a bug I thought I'd never have: dpaste.dzfl.pl/5c0ab8b8
It's pretty obvious what's going on from that code snippet. But in a
larger codebase where refactoring happens often it's easy to make a
mistake of leaving out a "dangling" if statement, which is exactly
what happened here.
It could be controversial, but maybe we should consider banning the
use of blank spaces between the beginning of a *non-blocked* if
statement and the next statement. IOW:
This is OK:
if (state) {
statement 1..
}
statement 2..
This is not ok:
if (state)
statement 1..
statement 2..
Thoughts?
More information about the Digitalmars-d
mailing list