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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 23 09:21:32 PDT 2010


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


Jonathan M Davis <jmdavisProg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmail.com


--- Comment #1 from Jonathan M Davis <jmdavisProg at gmail.com> 2010-06-23 09:21:28 PDT ---
Except that then you have to make the compiler understand indentation. I don't
believe that it cares at all about indentation at this point. Whitespace is
whitespace. It doesn't matter how much of it that there is; it just matters if
there is any.

Requiring it to be able to understand indentation well enough to alert the
programmer as to where they used it incorrectly or to complain that the
programmer has used it in a manner which could be ambiguous to a human reader
would likely complicate things quite a bit for the compiler.

The current situation is totally unambiguous. It's just that it doesn't stop
the programmer from being stupid with how much indentation they use and thereby
throwing off other programmers who don't read their code carefully (or they
themselves when they read it later).

Also, it could be rather nasty to code generators, since then they'd have to
worry a lot more about making code human-readable - which while potentially
nice probably isn't necessary in many cases.

I believe that the usual solution if a programmer is worried about this sort of
thing is just to use a coding standard that always requires braces for the
bodies of if-else statements, loops, etc.

-- 
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