English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] The Makefile
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-03-05 (04:42)
From: William Lovas <wlovas@s...>
Subject: Re: [Caml-list] Test case syntax error
On Thu, Mar 04, 2004 at 07:25:46PM -0800, Vasili Galchin wrote:
> 1) It gets a syntax error on the ending "done" for the
> "while true". I have tried trimming down and still the
> syntax error. I am sorry for something so elementary.
> Can anyone help?

Let's look at the code:

>                while true do
>                   let (buffer:string) = "" in
>                      (* Do blocking read! *)
>                      let (x, y) = Unix.recvfrom descr buffer 0 128 [MSG_OOB]
>                done

An expression belongs inside the `do ... done' of a while loop, and any
`let' expression needs an `in'.  (Be careful not to confuse the `let ...
in ...' _expression_ with the `let ...' _top-level declaration_.)  What do
you want to do with that (x, y) pair after you've bound it?

> 2) I am running on Linux. I did a "man ocamlc" to see
> what kind of compiler switches there are. Is there a
> compiler switch that gives a more verbose/helpful
> error than simply "syntax error"?

None that i'm aware of, but after you spend enough time with O'Caml's
syntax, the location of the error is usually enough.


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners