Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Jan Skibinski <jans@numeric-quest.com>, caml-list@inria.fr
Subject: Re: Dynamic usage of Ocaml evaluator?
Date: Mon, 22 Jun 1998 11:00:36 +0200	[thread overview]
Message-ID: <19980622110036.30478@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.LNX.3.95.980618023921.13536B-100000@info.numeric-quest.com>; from Jan Skibinski on Thu, Jun 18, 1998 at 03:48:42AM -0500

For several reasons, "eval" is hard to support well in Caml.  There
are typing issues, of course.  Also, the Caml Light and Objective Caml
implementations are more targeted towards batch compilation than
towards run-time code generation.  (Remember, those two
implementations are not interpreters, but full compilers.)

This said, your solution with Toploop.run_script is reasonable, and
probably the simplest way to get what you want.  I'm assuming you're
not concerned about security, as it allows embedded scripts to do
pretty much anything the user could do (e.g. by calling Sys.command).

An alternate solution would be to compile the ML source by calling the
ocamlc compiler, then load the compiled bytecode using the Dynlink
library.  This allows more precise control on what the user code has
access to.  However, in your particular case it doesn't make much
sense to generate a .cmo file that you're going to use only once.

> Is there any better way to do it? Is the code below correct? It works,
> but I am afraid that it might leave the toplevel in some unstable state.
> Normally I do exit from the toplevel after I finished producing the
> document (70 or so pages), but I wonder what might go wrong on a long
> run?

I think it should work fine.  Some of the bytecode will accumulate in
memory (i.e. the bytecode for the functions defined in the embedded ML
text), but you'd really need large quantities of embedded ML before
that becomes noticeable.

Regards,

- Xavier Leroy





      reply	other threads:[~1998-06-23  0:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-18  8:48 Jan Skibinski
1998-06-22  9:00 ` Xavier Leroy [this message]

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=19980622110036.30478@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jans@numeric-quest.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