caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Even at compile time 2*2=4!
@ 2002-11-19  3:18 Jakob Lichtenberg
  2002-11-19 11:11 ` Alessandro Baretta
  2002-11-19 11:12 ` Daniel de Rauglaudre
  0 siblings, 2 replies; 6+ messages in thread
From: Jakob Lichtenberg @ 2002-11-19  3:18 UTC (permalink / raw)
  To: caml-list

Fellow O'Caml hackers,

I have this complicated module 'fourLib.ml' that binds the value 'four' to
the *computed* value of four:
---
let four = (Printf.printf "Now we do the complicated calculation of
2*2...\n";
            let res = 2*2
            in res);
---

A sample application 'sixteen.ml':
---
let _ = Printf.printf "4 * 4  is %d" (FourLib.four * FourLib.four);
---


I wish to package/compile my 'fourLib' so that I can avoid doing the
complicated calculation '2*2' each and every time I load 'fourLib'.  (I am
sure that you can imagine an even more requiring computational task than
evaluating '2*2'.)


Currently I build as follows:
  > ocamlc -c fourLib.ml
  > ocamlc  -c sixteen.ml
  > ocamlc -o sixteen fourLib.cmo sixteen.cmo

Unfortunately 2*2 is first calculated when I run the application:
  > ./sixteen
  Now we do the complicated calculation of 2*2...
  4 * 4  is 16
---

1. I am willing to rewrite the library, the way stuff is build, etc....  I
basically just want ocaml to evaluate 2*2 before the final linking.  Is my
only hope to serialize Four.four and then load it?


2. Can I build a new top-level interactive environment 'ocaml_with_fourLib'
where this module is 'pre-loaded'.  Again, the actual calculation of 2*2
should be done when I build ocaml_with_fourLib - not when I start it.

Thanks,

- Jakob Lichtenberg

--
Jakob Lichtenberg - jl@itu.dk - http://www.itu.dk/people/jl/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-11-20  8:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-19  3:18 [Caml-list] Even at compile time 2*2=4! Jakob Lichtenberg
2002-11-19 11:11 ` Alessandro Baretta
2002-11-20  0:31   ` Pierre Weis
2002-11-20  8:42     ` Alessandro Baretta
2002-11-19 11:12 ` Daniel de Rauglaudre
2002-11-19 18:09   ` David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).