From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA10098; Thu, 8 Apr 2004 09:50:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA10274 for ; Thu, 8 Apr 2004 09:50:16 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i387p6jq023482 for ; Thu, 8 Apr 2004 09:51:08 +0200 Received: from [192.168.1.200] (ppp116-94.lns1.syd2.internode.on.net [150.101.116.94]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i387nveZ082944; Thu, 8 Apr 2004 17:20:02 +0930 (CST) Subject: Re: [Caml-list] Dynamically evaluating OCaml code From: skaller Reply-To: skaller@users.sourceforge.net To: John Goerzen Cc: Vitaly Lugovsky , caml-list In-Reply-To: <20040407203938.GC26323@excelhustler.com> References: <20040407203938.GC26323@excelhustler.com> Content-Type: text/plain Message-Id: <1081410596.19232.884.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 08 Apr 2004 17:49:57 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 dynamically:01 sourceforge:01 2004:99 2004:99 0400,:01 vitaly:01 lugovsky:01 wrappers:01 endline:01 fragment:01 interscript:01 vastly:01 python:01 'eval':01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 129 On Thu, 2004-04-08 at 06:39, John Goerzen wrote: > On Thu, Apr 08, 2004 at 01:32:41AM +0400, Vitaly Lugovsky wrote: > I don't think that will help me here; I'm looking at being able to let > people insert OCaml expressions directly into otherwise plain-text > config files. Yeah, you can do that! But you need to be tricky! Analyse the file, changing the plain text parts to strings. You may need some wrappers like: option5 = /dev/null becomes print_endline "option5 = /dev/null" Now you can compile the file with Ocaml, and execute it. This is very nice because you WILL be typechecking the code fragments. Indeed you can do better, by making the client write the WHOLE file in psuedo code that translates to Ocaml, then the code executes things, instead of just printing a text file to be run through bash, or some other text interpreter. By the way the code fragment technique is exactly what my interscript literate programming tool does, which makes it vastly superior to similar tool: it embeds Python though, which does have 'eval'. You might want to use it instead..since it already does what you want .. and happens to be able to pretty print HTML documentation as well :D -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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