Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Module initialiser functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] Module initialiser functions
Hi,

Is it guaranteed that the initialisers for each module will be run in
the order of modules specified to the ocaml compiler?

Say, with the given Makefile:

ML	 = ocaml/device.ml ocaml/keyboard.ml ocaml/console.ml
ocaml/thread.ml ocaml/irq.ml ocaml/kernel.ml
MLI	 = $(wildcard ocaml/*.mli)
CMX	 = $(ML:.ml=.cmx)

OCAMLKERNEL	= ocaml/ocamlkernel.o

$(OCAMLKERNEL): $(CMX)
	$(OCAMLOPT) -linkpkg $(CMXA) $(CMX) -output-obj -o $@

For instance: I want to have it such that keyboard.ml registers a
device during init, and then console.ml registers a device which
depends on opening the keyboard device earlier registered.

But the only way this is guaranteed to work is if I can make some sort
of guarantees about the order that initialisers are called at the
module level. Does ocaml make any sort of guarantees like this? Or
will depending on this to happen be too fragile?

Jonathan