caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alessandro Baretta <alex@baretta.com>
To: Jakob Lichtenberg <jl@itu.dk>, ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Even at compile time 2*2=4!
Date: Tue, 19 Nov 2002 12:11:36 +0100	[thread overview]
Message-ID: <3DDA1C68.5070909@baretta.com> (raw)
In-Reply-To: <001901c28f7a$5a7feb30$3101000a@redmond.corp.microsoft.com>



Jakob Lichtenberg wrote:

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

I wish to suggest one possibility.

1) You write a module defining the type of the datastructure 
you wish to precompute and load
2) You write a program importing the above module, which 
computes the datastructure and marshals it to a file. You 
run this program.
3) You write a library which, upon being loaded, searches 
the filesystem for the appropriate file, unmarshals it and 
binds the precomputed data to an identifier.
4) You write your programs referring to the the identifier 
exported by #3.

eg.

module: type_of_four.ml
*********************
type four = int


module: compute_four.ml
**********************
open Type_of_four

let four:four = 2 * 2

let _ = Marshal.to_channel (open_out "foo") four []


module: four.ml
***************
open Type_of_four

let (four:four) = Marshal.from_channel (open_in "foo")


module: sixteen.ml
******************
open Four

let sixteen = four * four


Cheers,
Alex

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


  reply	other threads:[~2002-11-19 11:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-19  3:18 Jakob Lichtenberg
2002-11-19 11:11 ` Alessandro Baretta [this message]
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=3DDA1C68.5070909@baretta.com \
    --to=alex@baretta.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;
as well as URLs for NNTP newsgroup(s).