Is "if ... else if ... else ..." any other than "if ... else {if ... else ...}" semantically?

I believe that all of you, while studying C, have learned this syntax:

if (condition 1) {
    statements
} else if (condition 2) {
    statements
} ...
else {
    statements
}

But after reading N1570, § 6.8.4.1 Operatorif , I absolutely do not say anything about encoded operators else if, unlike other languages ​​that provide keywords for this, such as ElseIfor elif.

In my opinion, the whole if(...){...}else{...}is one single statement (a sentence elsemay not exist, which does not matter). Therefore, when it comes to parsing, as shown in the codes below,

if (condition) {}
else
    one_statement;
if (condition) {}
else
    if (something else) {} else {}

- if one_statement; "" "unit".

, C , , . ,

if (condition) {
} else if (something else) {
} else {
}

?

+4
1

else if if

, if, , , , if . , else, else :

if (x)
    ...
else if (y)
         ...
     else if (z)
             ...
          else
             ...

, if (y) else if (x), . , , .

: C dangling else, , if , .

+2

Source: https://habr.com/ru/post/1696011/


All Articles