3 ms·
When I saw OCaml the first time I saw a much different syntax than this: lots of double semicolons (and lots more single semicolons than were present here). Thi
by koenigdavidmj 12y ago
When I saw OCaml the first time I saw a much different syntax than this: lots of double semicolons (and lots more single semicolons than were present here). This looks much like Standard ML instead. What's up with that?
- tomp 12y agoDouble semicolons are used in the OCaml REPL to evaluate the current input (instead of newlines as in e.g. Python REPL). They don't need to be used in .ml files.
- sampo 12y agoIf you write in imperative style (using expressions for their side effect and discarding their return values) then you separate statements with a ;. But for code written in functional style, there will be no ;'s. Then ;; is used to separate statements at the top level. But in most of the cases when a new top level statement begins, OCaml can understand this anyway and you can omit the ;;. Or use the ;; if you prefer that style. So, imperative code is as full of ;'s as C code, and toplevel use of ;; is a stylistic issue. https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Usingandomittingand https://ocaml.org/learn/tutorials/structure_of_ocaml_program...