From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,HTML_MESSAGE,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B159ABC69 for ; Wed, 30 May 2007 17:27:52 +0200 (CEST) Received: from mail-red.research.att.com (mail-red.research.att.com [192.20.225.110]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4UFRp34021958 for ; Wed, 30 May 2007 17:27:52 +0200 Received: from [135.207.25.107] (yitzhakmac.research.att.com [135.207.25.107]) by bigmail.research.att.com (8.13.7+Sun/8.11.6) with ESMTP id l4UFRnMW029825 for ; Wed, 30 May 2007 11:27:49 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v752.3) To: caml-list@yquem.inria.fr Message-Id: <7D7BAFC8-9689-4985-B6AE-E83AB95398C4@research.att.com> Content-Type: multipart/alternative; boundary=Apple-Mail-15-368175154 From: Yitzhak Mandelbaum Subject: scripting the toplevel Date: Wed, 30 May 2007 11:27:17 -0400 X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 465D97F7.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 465D97F7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; yitzhak:01 mandelbaum:01 yitzhak:01 toplevel:01 ocaml:01 toplevel:01 argv:01 expr:01 argv:01 expr:01 ocaml:01 mandelbaum:01 expression:02 expression:02 parameters:02 --Apple-Mail-15-368175154 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, I'm interested in writing scripts that can execute code in the ocaml toplevel as if the user had added the input by hand. In particular, I'd like to let the user pass parameters to my script and then use those. For example, let user_module = Sys.argv.(1);; #load user_module;; Or, more ambitiously, let user_expr = Sys.argv.(1);; user_expr;; The first example doesn't work, as #load needs a string literal and the second example works, but does not produce the desired effect - that of interpreting and executing an ocaml expression passed on the command line. Currently, to get around these limitations I'm collecting the user's parameters, using them to fill in a script template, dumping the filled-in template into a temp file, and then executing "ocaml" on the temp file. I'd prefer to avoid this level of complexity. Thanks, Yitzhak Mandelbaum -------------------------------------------------- Yitzhak Mandelbaum AT&T Labs - Research http://www.research.att.com/~yitzhak --Apple-Mail-15-368175154 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Hi,

I'm interested in writing = scripts that can execute code in the ocaml toplevel as if the user had = added the input by hand. In particular, I'd like to let the user pass = parameters to my script and then use those. For example,

let user_module =3D = Sys.argv.(1);;
#load user_module;;

Or, more = ambitiously,

let user_expr =3D = Sys.argv.(1);;
user_expr;;

The first example doesn't = work, as #load needs a string literal and the second example works, but = does not produce the desired effect - that of interpreting and executing = an ocaml expression passed on the command line.=A0 Currently, to get = around these limitations I'm collecting the user's parameters, using = them to fill in a script template, dumping the filled-in template into a = temp file, and then executing "ocaml" on the temp file. I'd prefer to = avoid this level of complexity.

Thanks,
Yitzhak = Mandelbaum

= --Apple-Mail-15-368175154--