Dangling if

Iain Buclaw ibuclaw at ubuntu.com
Mon Oct 1 09:52:53 PDT 2012


On 28 September 2012 02:43, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> 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?

Use an editor that indents code correctly. (I use vim ;-)


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the Digitalmars-d mailing list