From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id B4FC2BC88 for ; Mon, 7 Feb 2005 17:55:38 +0100 (CET) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j17GtchX009872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 7 Feb 2005 17:55:38 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1CyCAb-00075d-Me for caml-list@yquem.inria.fr; Mon, 07 Feb 2005 16:55:29 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml expression evaluated in a OCaml program Date: Mon, 7 Feb 2005 16:47:29 +0000 User-Agent: KMail/1.7.1 References: <4207705F.4030501@nemoworld.info> <4207948D.6030705@yahoo.fr> <420793B9.3020504@neometsys.fr> In-Reply-To: <420793B9.3020504@neometsys.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200502071647.29407.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 42079D8A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 ocaml:01 wrote:01 wrote:01 runtime:01 toplevel:01 ocamlopt:01 marshalling:01 compiler:01 ...:98 ...:98 ....:98 frog:98 expression:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Monday 07 February 2005 16:13, Nicolas Dufour wrote: > sejourne_kevin wrote: > > Nicolas Dufour a =E9crit : > >> I try to know if I can evaluate OCaml expressions in a OCaml program > >> during runtime ?? > > > > This is not possible. But you can try something with the toplevel: > > http://caml.inria.fr/archives/200404/msg00282.html > > damned .. not possible ..... > I hope it exists scriptic languages embedded in ocaml ... or i will have > to create one ... oh boy .... I've done exactly this though, by spitting out an ocaml program, compiling = it=20 with ocamlopt (linked against the running program) and invoking it using=20 marshalling to shuffle data back and forth. This is quite easy to implement= =20 and is the simplest way to write a JIT compiler in ocaml. If you don't really want to execute ocaml code but, rather, simple expressi= ons=20 then you can write your own interpreter quite easily. Many tutorials cover= =20 this. If you want to provide access to a few calls in your interpreter then= =20 you can simply implement them in your own little language. There are many=20 tutorials on ocaml which describe simple interpreters. =2D-=20 Dr Jon D Harrop, Flying Frog Consultancy Ltd.