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=0.3 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3BEB3BC69 for ; Fri, 1 Jun 2007 12:28:54 +0200 (CEST) Received: from server2.thinkcrime.de (server2.thinkcrime.de [213.133.110.149]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l51ASrjQ003620 for ; Fri, 1 Jun 2007 12:28:54 +0200 Received: from hod-sarge-2005-10.lan.m-e-leypold.de (dslb-088-072-201-045.pools.arcor-ip.net [88.72.201.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server2.thinkcrime.de (Postfix) with ESMTP id 5445548800D for ; Fri, 1 Jun 2007 12:28:54 +0200 (CEST) Received: by hod-sarge-2005-10.lan.m-e-leypold.de (Postfix, from userid 1003) id 6579837BC9; Fri, 1 Jun 2007 12:38:08 +0200 (CEST) To: caml-list@yquem.inria.fr Subject: Re: Res: [Caml-list] scripting the toplevel References: <20070601041515.6665.qmail@web51612.mail.re2.yahoo.com> Organization: Leypold, Software-Dienstleistungen und -Beratung From: "Markus E.L." Date: Fri, 01 Jun 2007 12:38:08 +0200 In-Reply-To: <20070601041515.6665.qmail@web51612.mail.re2.yahoo.com> (Alexsandro Soares's message of "Thu, 31 May 2007 21:15:15 -0700 (PDT)") Message-ID: <634plsm033.fsf@hod.lan.m-e-leypold.de> User-Agent: Some cool user agent (SCUG) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 465FF4E5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; toplevel:01 markus:01 markus:01 gerd:01 stolpmann's:01 toplevel:01 findlib:01 ocaml:01 ocamlopt:01 afaik:01 bytecode:01 ocamlmktop:01 invoke:01 compile:01 compile:01 > Hi Markus, > > I found your example very instructive. Thanks. > I need generate expressions on the fly and evaluate them many times during program execution. Somehow I have a gut feeling, that this might not be such a good idea: At least it sounds inbelievable dirty. I used Gerd Stolpmann's trick only to implement new toplevel directives (I wanted to add findlib paths using a toplevel directive), specifically invoke toplevel directives from others at the beginning of ocaml scripts. I'm not sure what happens if you do that in a loop ... > I would like to know how to compile your program using ocamlopt. Is > it possible? No. The module Toplevel is only available in the Toplevel, AFAIK. > How can I do it? Your program needs to be executed by the toplevel. You can compile your application modules to bytecode and add them to the toplevel with ocamlmktop. At the top of it all there must be a script, even if it only consists of 'MainApp.main ()'. Now that I think about it, I wonder wether it would not suffice that MainApp's init code would contain an infinite loop: The new toplevel never would go to interacting, but execute your application. Try it? Regards -- Markus