caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David MENTRE <dmentre@linux-france.org>
To: Tom <tom.primozic@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Dynamic loading of bytecode
Date: Mon, 14 Aug 2006 17:42:47 +0200	[thread overview]
Message-ID: <87oduniars.fsf@linux-france.org> (raw)
In-Reply-To: <c1490a380608140821q497970cfr6a8f091ec73b19ef@mail.gmail.com> (tom.primozic@gmail.com's message of "Mon, 14 Aug 2006 17:21:25 +0200")

Hello,

Tom <tom.primozic@gmail.com> writes:

> Say I have files a.ml:
>
>   let f x = x - 1
>
> and b.ml:
>
>   let g x y = x + f y - f x

    let g x y = x + A.f y - A.f x

>
> and I compile them into bytecode
>
>   ocamlc -c a.ml
>   ocamlc -c b.ml
>
> and then I want to be able to load them into the toploop so that I could
> access both modules A and B:
>
>   # let simplify x = B.g x - A.f x
>
>
> How do I do that?

* In command line given to ocaml toplevel:

$ ocaml a.cmo b.cmo
        Objective Caml version 3.08.3

# B.g 1 2;;


* Inside the toplevel, you need to #load each bytecode file:

$ ocaml
        Objective Caml version 3.08.3

# #load "a.cmo";;
# #load "b.cmo";;
# let simplify x = B.g x x - A.f x;;
val simplify : int -> int = <fun>


TFM: http://caml.inria.fr/pub/docs/manual-ocaml/manual023.html

Best wishes,
d.

PS: This kind of question might better go to caml-beginners@ mailing
    list. 
-- 
GPG/PGP key: A3AD7A2A David MENTRE <dmentre@linux-france.org>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A


  reply	other threads:[~2006-08-14 15:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-14 15:21 Tom
2006-08-14 15:42 ` David MENTRE [this message]
2006-08-17 11:48 ` [Caml-list] " Xavier Leroy
2006-08-18  1:15 ` Pietro Abate

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=87oduniars.fsf@linux-france.org \
    --to=dmentre@linux-france.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=tom.primozic@gmail.com \
    /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).