Why is `let a = 1; let b = 0;;` wrong?

why does

let a = 1; let b = 0;;

result in syntax error? Why is that sequencing of statements not valid in ocaml?

Your intended meaning seems to be

let a=1 and b=0;;

Ocaml combines a functional aspect (let …=… and …=… in …) with an imperative aspect (the operators :=,<-, the keywords do,done, while, etc).

The imperative aspect is much like C, and an imperative instruction can be terminated by a semicolon (although the semicolon is optional in many cases). The problem here is that you’re using a semicolon in a “purely functional” instruction.

1 Like