From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 45CBF7EEEF for ; Mon, 22 Jun 2015 17:48:23 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.13,660,1427752800"; d="scan'208";a="137359464" Received: from mail-yk0-f170.google.com ([209.85.160.170]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 22 Jun 2015 17:48:22 +0200 Received: by ykdr198 with SMTP id r198so132828413ykd.3 for ; Mon, 22 Jun 2015 08:48:21 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.146.20 with SMTP id j20mr36938528ywg.62.1434988101674; Mon, 22 Jun 2015 08:48:21 -0700 (PDT) Received: by 10.37.216.77 with HTTP; Mon, 22 Jun 2015 08:48:21 -0700 (PDT) In-Reply-To: <1434982765.31996.19.camel@e130.lan.sumadev.de> References: <1434982765.31996.19.camel@e130.lan.sumadev.de> Date: Mon, 22 Jun 2015 11:48:21 -0400 Message-ID: From: Damien Doligez To: Gerd Stolpmann Cc: Alan Schmitt , OCaml Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] use of ";;" when teaching Ocaml Gerd has totally nailed it, and that's the reason why I always use ;; in my code. If we had another keyword for toplevel let (let without in) the situation would be quite different. -- Damien On Mon, Jun 22, 2015 at 10:19 AM, Gerd Stolpmann wrote: > 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 > ------------------------------------------------------------ >