> Could Dart use this solution, which Python uses and Oil shell now uses?
This works well for Python, because the following causes IndentationError:
x = 1
+ 2
In a language without significant indentation, would this be two statements, an assignment and a separate unary `+` expression? Is that OK?
If not, one possible solution would be to disallow arbitrary expression statements. AFAIK this is what Go does.
> JavaScript has some weird rules, the common gotcha seems to be `return \n {...}`
Disallowing expression statements also fixes this particular example, but it doesn't solve the `return` problem in general. It's not practical to disallow standalone function calls, so `return \n f()` still has the same issue.
Lua solves this by enforcing that a `return` must be the last statement in a block.
> It's not practical to disallow standalone function calls
If your language structurally differentiated procedures (i.e., void-returning functions) from (other) functions, it would be practical to disallow standalone functions (not procedures), though you might have a modifier to explicitly discard the result of a function that allows it to be standalone.
This works well for Python, because the following causes IndentationError:
In a language without significant indentation, would this be two statements, an assignment and a separate unary `+` expression? Is that OK?If not, one possible solution would be to disallow arbitrary expression statements. AFAIK this is what Go does.
> JavaScript has some weird rules, the common gotcha seems to be `return \n {...}`
Disallowing expression statements also fixes this particular example, but it doesn't solve the `return` problem in general. It's not practical to disallow standalone function calls, so `return \n f()` still has the same issue.
Lua solves this by enforcing that a `return` must be the last statement in a block.