Why is:
print_int 3; let x = 3;;
Error: Syntax error
a syntax error but not:
(print_string "Hi\n"; 3 > 1) || 4 > 6;;
Hi
do I just not understand the syntax for sequencing expressions or something?
Why is:
print_int 3; let x = 3;;
Error: Syntax error
a syntax error but not:
(print_string "Hi\n"; 3 > 1) || 4 > 6;;
Hi
do I just not understand the syntax for sequencing expressions or something?
“let” without “in” is a toplevel statement
single “;” is between 2 expressions
Gaëtan Gilbert
Binding sequencing is via let <binding> = <expr> in <rest>
, non-binding sequencing (returning unit ()
) is via the ;
operator, which is used like <expr-that-returns-()> ; <rest>
. The ;
is roughly equal to let () = <expr> in <rest>
.