www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Dangling Else, Yet Again

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
http://www.reddit.com/r/programming/comments/kooiy/dangling_else_yet_again/

Andrei
Sep 22 2011
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:j5gv0j$825$1 digitalmars.com...
 http://www.reddit.com/r/programming/comments/kooiy/dangling_else_yet_again/

 Andrei
"It works by keeping track of any lexically enclosing statement that is looking for an else clause, so if an else clause is found for the current statement without a following { }, then it is marked as illegal." Can someone explain that for me? (My brain is completely scrambled right now from a nasty Flash/IE bug.)
Sep 22 2011
prev sibling parent deadalnix <deadalnix gmail.com> writes:
Le 23/09/2011 05:38, Andrei Alexandrescu a écrit :
 http://www.reddit.com/r/programming/comments/kooiy/dangling_else_yet_again/

 Andrei
This is a great idea. I'm used to use tools like checkstyle in java (or some others depending on the language) that trigger an error if an if statement without brace contain any conditionnal (if, for, while, . . .) or as an else. It makes the code myuch more clearer and avoid stupid mistake that sometime are hard to discover. Including this at the parser level is a great idea. The D's solution is softer than mine, but this is a good thing. At parser level, you should only limit what is error prone, not ensure coding quality standards that can vary from a devellopper to another. Good job. deadalnix
Sep 23 2011