From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p1QLiNj2019696 for ; Sat, 26 Feb 2011 22:44:23 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgADALMCaU3UGyoElGdsb2JhbACYNI4SFQEBAgkLCAkRAyK6fIVhBI9mDw X-IronPort-AV: E=Sophos;i="4.62,232,1297033200"; d="scan'208";a="100771006" Received: from smtp4-g21.free.fr ([212.27.42.4]) by mail1-smtp-roc.national.inria.fr with ESMTP; 26 Feb 2011 22:44:17 +0100 Received: from yeeloong (unknown [82.229.213.209]) by smtp4-g21.free.fr (Postfix) with SMTP id EA4694C828D for ; Sat, 26 Feb 2011 22:44:10 +0100 (CET) Received: by yeeloong (sSMTP sendmail emulation); Sat, 26 Feb 2011 22:44:04 +0100 Date: Sat, 26 Feb 2011 22:44:04 +0100 From: rixed@happyleptic.org To: caml-list@inria.fr Message-ID: <20110226214403.GA20532@yeeloong.happyleptic.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: [Caml-list] Calling the toplevel from the toplevel I'm trying to build an application that's run from the toplevel, using the toplevel to customize the application from itself (for instance, setting some global parameters using the toplevel to configure the application behavior while it's running). But I cannot allow the toplevel to read directly from stdin nor to write anything into stdout (since my application uses ncurses). I've looked for various ways to do this, and the simpler I found to prevent the toplevel to use stdout is to call myself Toploop.execute_phrase with a custom formatter (so that I can display the output where and how I want). Up to now all seams to work except for minor annoyances : - I cannot start the application directly by linking the custom toplevel with something like "let _ = start_application ()" but I have to call "start_application();;" from the toplevel manually (or from the .ocamlinit file), otherwise the application bindings are not available. - I cannot let the user uses the toplevel directives "use" and "load" because both writes into stdout whatever the formatter passed to Toploop.execute_phrase (for "use" this is easily solvable by shadowing the toplevel implementation by another one that call Toploop.use_file with my own formatter, but for "load" I would have to copy a lot of code from topdirs.ml I'd like to know if it is safe to call the Toploop evaluation functions from code evaluated from the toplevel itself ? Or if someone can suggest a better way to prevent the toplevel from using stdout ?