Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Shawn Wagner <shawnw@s...>
Subject: Re: [Caml-list] Test case syntax error
On Thu, Mar 04, 2004 at 07:25:46PM -0800, Vasili Galchin wrote:
> Hello,
> 
>    I have added some functionality to the OCaml
> run-time library and I am trying to test. I wrote test
> case below that refuses to complile.
> 
> 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?
> 
> 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"?
> 
> Regards, vasili
> 
> ----------------------------test case-----------------
> 
> (* The multicast listener *)
> let listen ((my_addr_octet:string),
> (multicast_addr_octet:string), multicast_port) =

You don't have to specify types like this. Let the compiler figure it out
instead. :) It's also an odd style to take all the arguments in one tuple,
instead of making them curry-able:

let listen my_addr_octect multicast_addr_octet multicast_port = ...


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

You need an 'in' after the let binding, and code following that.

>                done
>           with
>              _ -> Printf.printf "%s\n" "blah";;     

-- 
Shawn Wagner
shawnw@speakeasy.org

-------------------
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