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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-04 (15:54)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: Re: [Caml-list] beginner
On Tue, 4 Jul 2006, Aws Albarghouthi <albargah@mcmaster.ca> wrote:
> I am an ocaml beginner and I am trying to modify an open source  
> application. I'm facing the problem that functions within a file  
> can't call each other. I'm getting the error Unbound value <func name>.

This is normal.

  let f ... = ...
  let g ... = ...

The function g can use f but f cannot call g because g is not known at
that point.  If f must also call g, then f and g are mutually
recursive and you should declare them as

  let rec f ... = ...
  and g ... = ...

You can also group your functions as methods of an object (these can
call each other) :

  method f ... = ... self#g ...
  method g ... = ... self#f ...