From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 11E4FBC69 for ; Tue, 21 Aug 2007 20:33:43 +0200 (CEST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7LIXgk6010203 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 21 Aug 2007 20:33:42 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1INYXo-0008Vh-00; Tue, 21 Aug 2007 19:33:36 +0100 Date: Tue, 21 Aug 2007 19:33:36 +0100 To: David Allsopp Cc: "'Caml-list List'" Subject: Re: [Caml-list] If OCaml were a car Message-ID: <20070821183335.GA32626@furbychan.cocan.org> References: <20070819170704.GA10089@furbychan.cocan.org> <005a01c7e3ca$0ce14fa0$6a7ba8c0@treble> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <005a01c7e3ca$0ce14fa0$6a7ba8c0@treble> User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at discorde with ID 46CB3006.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 0100,:01 o'caml:01 syntax:01 emacs:01 ocaml:01 command-line:01 argv:01 wrote:01 avoids:01 caml-list:01 define:02 rarely:02 variables:02 variables:02 On Tue, Aug 21, 2007 at 09:05:33AM +0100, David Allsopp wrote: > (* first function *) > let f x = (* definition of f *) > in > let g x = (* definition of g *) > (* etc, etc *) > > (* next function *) > let h x = (* definition of *) > > Here, O'Caml helpfully tells me that there's a syntax error on line 7 which > is of course complete rubbish!! It may be easy to spot here, but I've > absent-mindedly missed the final part of a bigger function mid-development I find that using tuareg-mode (an Emacs mode for OCaml) generally avoids this problem. [...] > I'd go one further - and recommend that all top level statements are > function definitions (there's so rarely a need to use global "variables"... > it usually comes back to bite you at some point later). Then define a No I use top level "variables" all the time. It depends what sort of program you're writing, but for once-through command-line programs you will often do things like: let dbname = (* something involving Sys.argv *) ;; let dbh = PGOCaml.connect ~dbname () ;; Rich. -- Richard Jones Red Hat