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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Junbiao Zhang <junzhang@c...>
Subject: forward function definitions
Hi,

	We're developing a fairly large system with multiple function
definitions. It's inevitable that some functions may call other functions
defined later(may not even be recursive calls as in the case of
Sys.Signal_handle). My question is: how do I solve such a problem which is
extremely trival in other languages?  Thanks. 

--Junbiao

My current solution is really ugly: 

let a_forward_ref = 
  (ref (fun _ -> raise (Failure "undefined") : int -> unit));;


let register_signals () = 
  .....
  Sys.signal Sys.sigalrm (Sys.Signal_handle !a_forward_ref)
  .....

.........

let a sigid = 
  ......

let assign_a_forward_ref () = 
  a_forward_ref := ref a	

And im main()(may be in another file):

  ......
  assign_a_forward_ref ()
  ......


I must be missing something or this language is:)