Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 1999-06-11 (23:07)
From: Junbiao Zhang <junzhang@c...>
Subject: forward function definitions

	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. 


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:)