Version française
Home     About     Download     Resources     Contact us    
Browse thread
beginner
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
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) :

object(self)
  method f ... = ... self#g ...
  method g ... = ... self#f ...
end

Cheers,
ChriS