3 ms·
The rational part of me screams that "else if" should be a single token, so I'm left with: elif, elsif or elseif. "else if" is really an old C hack that enable
by bluetomcat 11y ago
The rational part of me screams that "else if" should be a single token, so I'm left with: elif, elsif or elseif.
"else if" is really an old C hack that enables the parser to not have a special production for else-ifs, and it would generate a deep parse tree, rather than a flat one. I feel like that is wrong. A chain of if-elif-else should be conceptually linear, not nested.
Moreover, in a language that doesn't require parens around the conditions, it would look rather "disorientating":
} else if a == b && b == c {
- nikolay 11y agoOnly primitive parsers would be bothered by multiple tokens in a row - tey don't have to be one word, you don't even need a special separator - it's only needed in languages like Python. That's why Java, C#, JavaScript, and others don't need an "elif" equivalent - it's all a matter of code formatting and not nesting redundantly.