From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p1RC0GkD007485 for ; Sun, 27 Feb 2011 13:00:21 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqEGAMrLaU3VuiYS/2dsb2JhbACYNI4SdLljDYVUBA X-IronPort-AV: E=Sophos;i="4.62,234,1297033200"; d="scan'208";a="76689536" Received: from solaria.dimino.org ([213.186.38.18]) by mail3-smtp-sop.national.inria.fr with ESMTP; 27 Feb 2011 13:00:21 +0100 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 945158004D; Sun, 27 Feb 2011 13:00:20 +0100 (CET) Received: by aurora (Postfix, from userid 1000) id BA8E3402E5; Sun, 27 Feb 2011 13:00:27 +0100 (CET) Date: Sun, 27 Feb 2011 13:00:27 +0100 From: =?iso-8859-1?Q?J=E9r=E9mie?= Dimino To: rixed@happyleptic.org Cc: caml-list@inria.fr Message-ID: <20110227120027.GA3544@aurora> References: <20110226214403.GA20532@yeeloong.happyleptic.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20110226214403.GA20532@yeeloong.happyleptic.org> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Calling the toplevel from the toplevel On Sat, Feb 26, 2011 at 10:44:04PM +0100, rixed@happyleptic.org wrote: > 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. Actually you can, you just have to make sure that .cmi files are available in the search paths of the toplevel when you run your application. > - 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 Why not use Topdirs.dir_load with a custom formatter ? If you are interested, i started some time ago an emacs-like editor which can run in both curses and gtk mode and which integrates a toplevel. I add to face the same problems. I solved them by using Toploop.execute_phrase directly and redefining all directives. The code is available here: http://solaria.dimino.org/cgi-bin/darcsweb.cgi?r=peps;a=summary The file that may interest you is src/core/peps_top.ml Also another problem i had is that Toploop.execute_phrase does not prints errors on the given formatter but raises an exception instead, and the printer used in Toploop.loop (Errors.report_error) is in the module Errors for which the cmi is not available. I used a hack which consists on parsing the output of Toploop.use_silently (file peps_top.ml, function eval_command). -- Jérémie