From: "Jakob Lichtenberg" <jakob.lichtenberg@attbi.com>
To: <caml-list@inria.fr>
Subject: [Caml-list] Even at compile time 2*2=4!
Date: Mon, 18 Nov 2002 19:18:34 -0800 [thread overview]
Message-ID: <001901c28f7a$5a7feb30$3101000a@redmond.corp.microsoft.com> (raw)
Fellow O'Caml hackers,
I have this complicated module 'fourLib.ml' that binds the value 'four' to
the *computed* value of four:
---
let four = (Printf.printf "Now we do the complicated calculation of
2*2...\n";
let res = 2*2
in res);
---
A sample application 'sixteen.ml':
---
let _ = Printf.printf "4 * 4 is %d" (FourLib.four * FourLib.four);
---
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'.)
Currently I build as follows:
> ocamlc -c fourLib.ml
> ocamlc -c sixteen.ml
> ocamlc -o sixteen fourLib.cmo sixteen.cmo
Unfortunately 2*2 is first calculated when I run the application:
> ./sixteen
Now we do the complicated calculation of 2*2...
4 * 4 is 16
---
1. I am willing to rewrite the library, the way stuff is build, etc.... I
basically just want ocaml to evaluate 2*2 before the final linking. Is my
only hope to serialize Four.four and then load it?
2. Can I build a new top-level interactive environment 'ocaml_with_fourLib'
where this module is 'pre-loaded'. Again, the actual calculation of 2*2
should be done when I build ocaml_with_fourLib - not when I start it.
Thanks,
- Jakob Lichtenberg
--
Jakob Lichtenberg - jl@itu.dk - http://www.itu.dk/people/jl/
-------------------
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
next reply other threads:[~2002-11-19 10:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-19 3:18 Jakob Lichtenberg [this message]
2002-11-19 11:11 ` Alessandro Baretta
2002-11-20 0:31 ` Pierre Weis
2002-11-20 8:42 ` Alessandro Baretta
2002-11-19 11:12 ` Daniel de Rauglaudre
2002-11-19 18:09 ` David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001901c28f7a$5a7feb30$3101000a@redmond.corp.microsoft.com' \
--to=jakob.lichtenberg@attbi.com \
--cc=caml-list@inria.fr \
--cc=jl@itu.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox