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
Re: Let rec trouble
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-07-28 (16:36)
From: Christopher Oliver <oliver@f...>
Subject: Re: Let rec trouble
> > Um... I'm getting "syntax error" with OLABL 1.07.
> Not in O'Caml :)

Jacques Garrigue found the problem, and it likely applies to OCAML
as well.  I didn't terminate my open directives with a semicolon.
He say the compiler was expecting a top level definition rather than
a lambda binding because of this.  This version compiles just fine:

  open Num
  open Nat
  open Big_int
  open Ratio;;  (* Note the trailing statement delimiter. *)
  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
    print_string (string_of_num (n (Int 3) (Int 3)));;

Given that some of the system sources conspicuously omit the double
semicolons, maybe it would be good to document where this is permitted
and why, else people studying the compiler as example code will get
very confused.

Small question: is there any chance your CAML books will be available
in an English translation in the future?  While I can work my way
through something like "Miroir du Cyclism" with difficulty, my French
is hardly up to technical reading.  Also, I'd like something I can
recommend to colleagues who may have no exposure to French whatsoever.

Thank you,

Christopher Oliver                     Traverse Internet
Systems Coordinator                    223 Grandview Pkwy, Suite 108
oliver@traverse.net                    Traverse City, Michigan, 49684
let magic f = fun x -> x and more_magic n f = fun x -> f ((n f) x);;