caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Delaying module initialization
@ 2004-03-26 16:59 Richard Jones
  2004-03-26 17:26 ` Yamagata Yoriyuki
  2004-03-26 21:10 ` skaller
  0 siblings, 2 replies; 18+ messages in thread
From: Richard Jones @ 2004-03-26 16:59 UTC (permalink / raw)
  To: caml-list


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


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

end of thread, other threads:[~2004-03-29  6:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-26 16:59 [Caml-list] Delaying module initialization Richard Jones
2004-03-26 17:26 ` Yamagata Yoriyuki
2004-03-26 18:44   ` Richard Jones
2004-03-26 19:05     ` Remi Vanicat
2004-03-27 10:19       ` Richard Jones
2004-03-27 11:18         ` Xavier Leroy
2004-03-27 11:21           ` Richard Jones
2004-03-27 15:47             ` skaller
2004-03-27 12:38           ` Benjamin Geer
2004-03-27 16:04             ` skaller
2004-03-28 10:34               ` Jacques Garrigue
2004-03-28 23:51                 ` skaller
2004-03-28 23:58                 ` skaller
2004-03-29  0:35                   ` skaller
2004-03-29  3:36                     ` Jacques Garrigue
2004-03-29  6:10                       ` skaller
2004-03-27 15:41           ` skaller
2004-03-26 21:10 ` skaller

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).