forward function definitions

From: Junbiao Zhang (junzhang@ccrl.nj.nec.com)
Date: Wed Jun 09 1999 - 20:38:22 MET DST


Date: Wed, 9 Jun 1999 14:38:22 -0400 (EDT)
From: Junbiao Zhang <junzhang@ccrl.nj.nec.com>
To: caml-list@inria.fr
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:)



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET