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 MAA16349; Tue, 19 Nov 2002 12:11:19 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA16342 for ; Tue, 19 Nov 2002 12:11:19 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (host58-68.pool80116.interbusiness.it [80.116.68.58]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gAJBBH106249 for ; Tue, 19 Nov 2002 12:11:18 +0100 (MET) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id BD54F273AD; Tue, 19 Nov 2002 12:11:36 +0100 (CET) Message-ID: <3DDA1C68.5070909@baretta.com> Date: Tue, 19 Nov 2002 12:11:36 +0100 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Jakob Lichtenberg , ocaml Subject: Re: [Caml-list] Even at compile time 2*2=4! References: <001901c28f7a$5a7feb30$3101000a@redmond.corp.microsoft.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jakob Lichtenberg wrote: > > 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'.) I wish to suggest one possibility. 1) You write a module defining the type of the datastructure you wish to precompute and load 2) You write a program importing the above module, which computes the datastructure and marshals it to a file. You run this program. 3) You write a library which, upon being loaded, searches the filesystem for the appropriate file, unmarshals it and binds the precomputed data to an identifier. 4) You write your programs referring to the the identifier exported by #3. eg. module: type_of_four.ml ********************* type four = int module: compute_four.ml ********************** open Type_of_four let four:four = 2 * 2 let _ = Marshal.to_channel (open_out "foo") four [] module: four.ml *************** open Type_of_four let (four:four) = Marshal.from_channel (open_in "foo") module: sixteen.ml ****************** open Four let sixteen = four * four Cheers, Alex ------------------- 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