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 RAA08942; Fri, 26 Mar 2004 17:59:45 +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 RAA09118 for ; Fri, 26 Mar 2004 17:59:44 +0100 (MET) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2QGxhHd019882 for ; Fri, 26 Mar 2004 17:59:44 +0100 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1B6ugJ-0004wt-00 for ; Fri, 26 Mar 2004 16:59:43 +0000 Date: Fri, 26 Mar 2004 16:59:43 +0000 To: caml-list@inria.fr Subject: [Caml-list] Delaying module initialization Message-ID: <20040326165943.GA18734@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones 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; frisch:01 perl's:01 lwp:01 useragent:99 lwp:01 useragent:99 wrappers:01 'use':99 initialized:01 'use':99 wrappers:01 consumed:01 vectors:01 hashes:01 funcs:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 373 I have a problem with module initialization which manifests itself in perl4caml (thanks to Alaine Frisch for pointing this one out). Basically the perl4caml.cma / .cmxa library consists of lots of wrapper modules such as Pl_Template which wraps Perl's Template, and Pl_LWP_UserAgent which wraps LWP::UserAgent, etc. Each of these wrappers has to 'use' the corresponding Perl library when it is initialized. Each wrapper module has code similar to this: open Perl let _ = eval "use LWP::UserAgent" This is just a requirement of Perl, that you have to 'use' a library before you can actually use it. 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. This has two bad consequences: (1) Large amount of memory is consumed at start-up. (2) If you move the Perl library onto another machine (eg. if it's compiled and bundled into a .deb), then the library won't work unless all the corresponding Perl modules have been installed, which is very inconvenient. One way around this would be to force users of modules to explicitly initialize the wrapper, eg. by calling Pl_LWP_UserAgent.init () at the start of their program. But if they forget to do this, then bad things can happen. Another way would be to split the library into individual .cmos, although this might be inconvenient, and there are also tricky dependency issues - Eg. what if a wrapper depends on other wrappers being around? In Perl everything is dynamic so one library can depend on another library which doesn't exist, and as long as the other library isn't used, everything will be fine. This is not the case with OCaml. Does anyone have any other ideas how to solve this? Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes, trees, string funcs, pool allocator: http://www.annexia.org/freeware/c2lib/ ------------------- 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