I am designing a language. I am being troubled by what to call "else if". My language uses indentation for blocks, so I need a keyword for "else if".
Python uses "elif" (meh...) and Ruby uses "elsif" (yuck!). Personally, I hate to use abbreviations, so I don't want to use either of these. Instead, I am thinking of just using "else if", where an arbitrary number of spaces can appear between "else" and "if".
I've noticed that this doesn't occur very often in programming languages. C# has "yield return" as a keyword, but that's the only example I can think of.
Is there an implementation concern behind this? I've created my lex file and it accepts the keyword with no issues. I am worried there is something I haven't thought of.
As long as you don't allow inline comments/newlines, there's nothing wrong with multi-word keywords. The only thing is that else if
might be confusing for your language users, tempting them to write else while
or else for
. You'll have hard time explaining them that your else if
is a keyword and not two statements following each other.