Am Montag, den 22.06.2015, 15:31 +0200 schrieb Alan Schmitt: > Hello, > > In my Ocaml class, I tend to promote the use of ";;" to separate phrases > (I'm basically following > http://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Usingandomittingand > although I was not aware of this page when I created the course). My > motivation is to minimize the difference between using the top-level and > writing files. > > I am now wondering if this is a good practice. In a nutshell, would you > rather use > > #+begin_src ocaml > let x = 12;; > print_endline "Hello World!" > #+end_src > > or > > #+begin_src ocaml > let x = 12 > let () = print_endline "Hello World!" > #+end_src > > when teaching Ocaml? There is one downside of not using ";;", namely that you sometimes get syntax errors much later than necessary. E.g. in let x = do_this(); do_that(); let y = 6 let z = do_third_thing() you get the syntax error at the position of the third "let" although it is the extra semicolon at the end of the first definition. This can be very confusing, and it is a very good reason to use ";;" outside the toplevel. IMHO it is better to be honest about this issue. Because "let" is an open-ended construction the ";;" can be useful as end marker, and the compiler emits better error messages with more precise locations. Gerd > Thanks, > > Alan > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------