From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA15639; Tue, 19 Nov 2002 11:46:29 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA15360 for caml-list@pauillac.inria.fr; Tue, 19 Nov 2002 11:46:28 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA01563 for ; Tue, 19 Nov 2002 04:20:06 +0100 (MET) Received: from sccrmhc03.attbi.com (sccrmhc03.attbi.com [204.127.202.63]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gAJ3K4X13584 for ; Tue, 19 Nov 2002 04:20:05 +0100 (MET) Received: from tjakobl3 ([12.211.89.251]) by sccrmhc03.attbi.com (sccrmhc03) with SMTP id <2002111903184900300s4kn6e> (Authid: jakob.lichtenberg@attbi.com); Tue, 19 Nov 2002 03:18:49 +0000 Message-ID: <001901c28f7a$5a7feb30$3101000a@redmond.corp.microsoft.com> Reply-To: "Jakob Lichtenberg" From: "Jakob Lichtenberg" To: Subject: [Caml-list] Even at compile time 2*2=4! Date: Mon, 18 Nov 2002 19:18:34 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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