by Tyr42 · 4y ago · 0 comments
x = some_long_expression
+ another_long_expression
problem? In Python you need to be careful to wrap that in () or use a \ before the newline to avoid it parsing as two lines, e.g. x = some_long_expression;
+ another_long_expression;
In particular, if you have a builder expressions let x = someBuilder()
.setVal(x)
.build()
You'd need to wrap the entire thing in () to avoid it getting mad, right?So if you're going to terminate expressions with ), and start them with (, why not just terminate them with ; instead?
Javascript is a "Semicolons Optional" language, but it's actually the worst of both worlds, as you have to be very careful not to wrap lines like
function() {
some stuff;
return
really_long_named_thing;
}
As it'll just insert a ; on the return, returning undefined for you.I guess that's because in the REPL Python need's to know whether the line has finished yet or not. OCaml and F# uses two semicolons ';;' for that purpose, but only in the REPL. In Haskell you can use braces and semicolons or '{:' and ':}' in the REPL.
salary = 100500
newsalary = (salary * 0.02
+ salary)
newsalary will the same as salary. There are no diagnostics.Yes, you can fix it by moving the + up a line but this should be a purely style thing, not semantics.