Re: OLabl bug?

From: Jacques GARRIGUE (
Date: Tue Jul 28 1998 - 04:16:17 MET DST

Subject: Re: OLabl bug?
In-Reply-To: Your message of "Mon, 27 Jul 1998 15:06:50 -0400 (EDT)"
Message-Id: <>
Date: Tue, 28 Jul 1998 11:16:17 +0900
From: Jacques GARRIGUE <>

> I had originally sent this to the CAML mailing list, but I think, in
> restrospect, this should have been sent to you.
> While goofing around with bignums, I entered the following program
> for computing a crude bound on the van der Waerden number for length
> 3 and partition 3.
> open Num
> open Nat
> open Big_int
> open Ratio
> let rec n k l =
> let rec m i =
> if i =/ Int 0 then
> Int 1 else
> Int 2
> */ (m (pred_num i))
> */ (n (k **/ (m (pred_num i))) (pred_num l)) in
> if l =/ Int 2 then succ_num k else m k
> in
> print_string (string_of_num (n (Int 3) (Int 3)));;
> Pierre Weis tells me this is legal OCAML, but OLABL complains about
> a syntax error at the second in. What can you tell me?

He is slightly wrong: your program as such will raise a syntax error
in ocaml also. He took me some time to find it, because I was always
pasting your input in two times: first the open statements, and then
the let in, and if you do that there is no error.

This is not an olabl bug, neither really an ocaml one.
The problem is that you are mixing two syntaxes: the one with
terminator (;;), and the one without (nothing after open).
Normally the first syntax is to be used at toplevel, and the second in
files, but there are hacks in the parser to allow a certain level
of mixing, which is confusing, I must admit.

Seeing a let immediatly after an open declaration, the parser is
waiting for a definitional let, and not a let in. So it throws you
when the pairing "in" comes.

Two solutions: either you add a terminator between the open sequence
and the let, or you add a dummy toplevel let:

let _ =
  let ... in ...

(The second one is the only possibility when writing compiled modules)



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:15 MET