[Issue 4375] Require explicit braces when 'else' is ambiguous

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 21 14:17:23 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4375


Nick Sabalausky <cbkbbejeap at mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cbkbbejeap at mailinator.com


--- Comment #18 from Nick Sabalausky <cbkbbejeap at mailinator.com> 2011-08-21 14:17:14 PDT ---
"You can get into all kinds of confusion by perversely indenting the source
code, this particular one isn't special and so doesn't warrant special
treatment."

I disagree with this assessment. The whitespace is not the core problem here.
The core problem is that the construct "if(cond) stmt; if(cond) stmt; else..."
(with no braces) is generally confusing for people. The whitespace merely makes
for a more illustrative example. To demonstrate, the following code is
perfectly valid and works as intended, but despite that, it would still make a
lot of programmers very nervous anyway:

if(x == 17)
    if(useFoo) foo(); else bar();

While it's true there's plenty of general confusion that can be caused by
misleading whitespace, that's really a separate class of issues. It's a class
of issues that can certainly aggravate the "if if else" matter, but that's just
because, like you said, they can aggravate any situation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list