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 UAA17229; Fri, 26 Mar 2004 20:05:38 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA14920 for ; Fri, 26 Mar 2004 20:05:36 +0100 (MET) Received: from mwinf0602.wanadoo.fr (smtp6.wanadoo.fr [193.252.22.25]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2QJ5aHd003945 for ; Fri, 26 Mar 2004 20:05:36 +0100 Received: from vanicat.homelinux.org (ca-bordeaux-8-20.w80-8.abo.wanadoo.fr [80.8.80.20]) by mwinf0602.wanadoo.fr (SMTP Server) with ESMTP id BFEA054001DD for ; Fri, 26 Mar 2004 20:05:31 +0100 (CET) Received: from moi by vanicat.homelinux.org with local (Exim 4.30) id 1B6wdu-0004rp-KA for caml-list@inria.fr; Fri, 26 Mar 2004 20:05:22 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Delaying module initialization References: <20040326165943.GA18734@redhat.com> <20040327.022627.38703728.yoriyuki@mbg.ocn.ne.jp> <20040326184424.GA20895@redhat.com> From: Remi Vanicat Mail-Copy-To: never Date: Fri, 26 Mar 2004 20:05:22 +0100 In-Reply-To: <20040326184424.GA20895@redhat.com> (Richard Jones's message of "Fri, 26 Mar 2004 18:44:24 +0000") Message-ID: <8765cre8el.dlv@vanicat.homelinux.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 0900,:01 yamagata:01 yoriyuki:01 caml-list:01 2004:99 'use':99 wrappers:01 initialized:01 initialized:01 initializing:01 strace:01 3.07:01 ocamlc:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 379 Richard Jones writes: > On Sat, Mar 27, 2004 at 02:26:27AM +0900, Yamagata Yoriyuki wrote: >> From: Richard Jones >> Subject: [Caml-list] Delaying module initialization >> Date: Fri, 26 Mar 2004 16:59:43 +0000 >> >> > Now the problem is that any program which links with perl4caml.cma >> > appears to immediately 'use' every Perl module, even ones for wrappers >> > which the program doesn't actually need. >> >> Actually, no. Among the modules in the cma file, modules really >> initialized and linked are modules which contain values used in the >> main program. Other modules are not initialized. > > I had to go back and check this, but I'm pretty sure that it is > initializing all the modules. > > To verify this, I did: > > $ strace -o /tmp/log ocaml -I +perl > Objective Caml version 3.07+2 Well, you are using the interpreter. The interpreter cannot know which modules of the cma you use, so it load them all. The ocamlc compiler do know, and the compiled prgm don't need to load all those cma. > > # #load "perl4caml.cma";; > # > > I then looked at /tmp/log and verified that this loads libraries such > as LWP::UserAgent (I can see it opening those .pm file on disk). This > must, I assume, mean that the 'use' statements are being run. I've done a : moi@vanicat:~/lang/ocaml$ ocamlc -o prgm -I +perl perl4caml.cma test.ml moi@vanicat:~/lang/ocaml$ strace -o /tmp/log ./prgm and the/tmp/log contain no trace of any .pm. -- Rémi Vanicat ------------------- 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