Programming/언어론

dangling if-else

구차니 2014. 8. 13. 17:16
문득.. 내가 쓰는 문법이 댕글링 if-else를 생성하는거 같아서 찾아보니..
딱히 문제는 없도록 C언어에서 문법적으로 처리한다고 해서 한숨을 쉬는중..

일단 자바와 C C++은 인접한 if에 else가 붙는다고 한다.
Java, C and C++ have chosen to resolve the Dangling-Else ambiguity uses the following rule: 
An else keyword always associates with the nearest preceeding if keyword that does NOT cause a syntax error

[링크 : http://www.mathcs.emory.edu/~cheung/Courses/561/Syllabus/2-C/dangling-else.html]  

[링크 : http://en.wikipedia.org/wiki/Dangling_else]