Browse thread
If OCaml were a car
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-08-21 (18:33) |
From: | Richard Jones <rich@a...> |
Subject: | Re: [Caml-list] If OCaml were a car |
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