caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Toplevel - loading dependencies
@ 2009-01-09 14:23 Dawid Toton
  2009-01-09 14:33 ` [Caml-list] " Matthieu Dubuget
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dawid Toton @ 2009-01-09 14:23 UTC (permalink / raw)
  To: caml-list

Another problem with loading modules in the toplevel:
I need to use the module A. So I write:
#load "A.cmo"
to get a messsage "Reference to undefined global B"
So I prepend a line:
#load B.cmo
 and get another "undefined global". Then it repeats prohibitively many 
times.
This is resolving dependencies by hand, one by one.

The solution would be to have a special version of cmo that knows 
locations of all other cmo's it depends on.

In special cases I could use cma archives, but this is only applicable 
when there is well defined and stable set of modules I need.
But in practice the modules I use in ocaml scripts are constantly 
evolving. It leads to having multiple cma aggregates and maintaining 
their building description. Again, lots of work.

If I put everything into one big cma, then I have to recompile it every 
small change. It takes so long time, that it would make no sense to use 
the interpreter at all.

Could I ask ocamlbuild to produce proper loading preamble for my scripts?

What is the right solution?

Dawid


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

* Re: [Caml-list] Toplevel - loading dependencies
  2009-01-09 14:23 Toplevel - loading dependencies Dawid Toton
@ 2009-01-09 14:33 ` Matthieu Dubuget
  2009-01-09 17:14 ` Florent Monnier
  2009-01-09 17:53 ` Peng Zang
  2 siblings, 0 replies; 5+ messages in thread
From: Matthieu Dubuget @ 2009-01-09 14:33 UTC (permalink / raw)
  To: caml-list

Dawid Toton a écrit :

> What is the right solution?

What about camlfind?

Salutations

Matt


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

* Re: [Caml-list] Toplevel - loading dependencies
  2009-01-09 14:23 Toplevel - loading dependencies Dawid Toton
  2009-01-09 14:33 ` [Caml-list] " Matthieu Dubuget
@ 2009-01-09 17:14 ` Florent Monnier
  2009-01-09 18:13   ` Dawid Toton
  2009-01-09 17:53 ` Peng Zang
  2 siblings, 1 reply; 5+ messages in thread
From: Florent Monnier @ 2009-01-09 17:14 UTC (permalink / raw)
  To: caml-list

> If I put everything into one big cma, then I have to recompile it every
> small change. It takes so long time, that it would make no sense to use
> the interpreter at all.

in case you're doing so this way:
ocamlc -o my.cma mod1.ml mod2.ml mod3.ml mod4.ml

this will recompile everything,
but you can use in your makefile:
%.cmo: %.ml
        ocamlc.opt -c $<
my.cma: mod1.cmo mod2.cmo mod3.cmo mod4.cmo
        ocamlc.opt -a -o $@ $^

then you don't recompile everything, only the modified module

if there are dependencies between modules, just add additional rules:
modfoo.cmo: modfoo.ml modbar.cmi




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

* Re: [Caml-list] Toplevel - loading dependencies
  2009-01-09 14:23 Toplevel - loading dependencies Dawid Toton
  2009-01-09 14:33 ` [Caml-list] " Matthieu Dubuget
  2009-01-09 17:14 ` Florent Monnier
@ 2009-01-09 17:53 ` Peng Zang
  2 siblings, 0 replies; 5+ messages in thread
From: Peng Zang @ 2009-01-09 17:53 UTC (permalink / raw)
  To: caml-list; +Cc: Dawid Toton

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Shouldn't ocamldep be able to solve this?  It can read a source file and 
figure out the dependencies.  So you could in theory generate a fake source 
file that is just "open A" and it should figure out the set of dependencies 
for module A.

Peng

On Friday 09 January 2009 09:23:35 am Dawid Toton wrote:
> Another problem with loading modules in the toplevel:
> I need to use the module A. So I write:
> #load "A.cmo"
> to get a messsage "Reference to undefined global B"
> So I prepend a line:
> #load B.cmo
>  and get another "undefined global". Then it repeats prohibitively many
> times.
> This is resolving dependencies by hand, one by one.
>
> The solution would be to have a special version of cmo that knows
> locations of all other cmo's it depends on.
>
> In special cases I could use cma archives, but this is only applicable
> when there is well defined and stable set of modules I need.
> But in practice the modules I use in ocaml scripts are constantly
> evolving. It leads to having multiple cma aggregates and maintaining
> their building description. Again, lots of work.
>
> If I put everything into one big cma, then I have to recompile it every
> small change. It takes so long time, that it would make no sense to use
> the interpreter at all.
>
> Could I ask ocamlbuild to produce proper loading preamble for my scripts?
>
> What is the right solution?
>
> Dawid
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFJZ48PfIRcEFL/JewRAvcBAJ93neP1/3O6GCqImp4PP/UPTd/iCACfeyTn
zFNLx2UjBo6pkgb9z3a0NPk=
=6+qX
-----END PGP SIGNATURE-----


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

* Re: [Caml-list] Toplevel - loading dependencies
  2009-01-09 17:14 ` Florent Monnier
@ 2009-01-09 18:13   ` Dawid Toton
  0 siblings, 0 replies; 5+ messages in thread
From: Dawid Toton @ 2009-01-09 18:13 UTC (permalink / raw)
  To: caml-list

> in case you're doing so this way:
> ocamlc -o my.cma mod1.ml mod2.ml mod3.ml mod4.ml
> 
> this will recompile everything,
> but you can use in your makefile:
> (...)
> then you don't recompile everything, only the modified module
> 

Yes, with ocamlbuild I need not to recompile everything, but it's slow 
traversing even nothing-to-be-done tree:

Finished, 432 targets (411 cached) in 00:00:08.

It takes already 8 seconds if nothing is touched.

If I edit few files, it's worse:

Finished, 432 targets (256 cached) in 00:00:49.

I'm looking for alternatives.

That's why I try with scripting: keep core libraries compiled and run 
outermost parts with an interpreter.

Another idea is to change ocamlbuild to work dynamically: keep the 
dependency tree in memory and update it from time to time, watching 
files on disk.

Dawid


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

end of thread, other threads:[~2009-01-09 18:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09 14:23 Toplevel - loading dependencies Dawid Toton
2009-01-09 14:33 ` [Caml-list] " Matthieu Dubuget
2009-01-09 17:14 ` Florent Monnier
2009-01-09 18:13   ` Dawid Toton
2009-01-09 17:53 ` Peng Zang

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