Closed LPTK closed 9 months ago
Oh that's a good catch. We currently allow trailing commas in parenthesis sections but not outside of them...
We do want trailing commas as they're very convenient. Scala has them but forces a new line right afterwards. Maybe we could do that and only in argument positions...
The use of the
;;
statement separator and a;
sequencing operator, which was inspired by OCaml, just felt too weird an unnatural. Let's go back to something most programmers will more likely already be familiar with.A nice thing with the comma operator is that it gives us a way of succinctly but clearly discarding return values, by writing
foo(123), ()
instead oflet _ = foo(123) in ()
ordiscard(foo(123))
.A cons is that the meaning of the comma kind of becomes overloaded.
Another cons is that because we want to be consistent, we want to parse
if ... then foo(), 1 else bar(), 2
asif ... then (foo(), 1) else (bar(), 2)
, but this meansif
-then
-else
s now need parentheses when used in an argument list, as inbaz(A , (if ... then B1 else B2), C)
.The PR also makes a couple of improvements here and there.