Remix.run Logo
Blikkentrekker a day ago

The issue is that you find you very often want to break those roles. Python basically has `elif` because `else if` would make each branch nest one level deeper which isn't what one wants, except Python uses exceptions for flow control so you find yourself having to use `except ... try` as an analogue to `else if` but not `excetry` exists to do the same and stop the indentation.

There are many other examples. It exists to give people freedom. Also, while humans only go by intendation it's very hand for text editing and manipulation without requiring special per-language support to move the cursor say to the nearest closing brace and so forth.

Joker_vD a day ago | parent | next [-]

> Python basically has `elif` because `else if` would make each branch nest one level deeper which isn't what one wants

There are, of course, other ways to handle this. For instance, "else if <cond>:" could've been made legal à la Golang:

    IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .
XorNot a day ago | parent | prev [-]

I'm very okay with elif though because it makes it clear that the conditional is part of the chained block and not a brand new one.

Blikkentrekker 14 hours ago | parent [-]

The issue is that it's a special case that acknowledges where there are cases where the indentation level it logically requires isn't what programmers find pleasant, there are many more, that just don't have that special case, so it forces indentation that's unpleasant and unintuitive.