From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id AE7DDBC3C for ; Mon, 15 Aug 2005 15:35:25 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7FDZPfq025515 for ; Mon, 15 Aug 2005 15:35:25 +0200 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 PAA23937 for ; Mon, 15 Aug 2005 15:35:24 +0200 (MET DST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.173]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7FDZNYk025512 for ; Mon, 15 Aug 2005 15:35:23 +0200 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1E4f7b-00037J-00; Mon, 15 Aug 2005 15:35:23 +0200 Received: from [84.167.170.211] (helo=gate.lan.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1E4f7a-0006g1-00; Mon, 15 Aug 2005 15:35:22 +0200 Received: from flakew.lan.gerd-stolpmann.de (flakew.lan.gerd-stolpmann.de [192.168.0.32]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 78C62C17E; Mon, 15 Aug 2005 15:35:22 +0200 (CEST) Subject: Re: [Caml-list] Usability problems with ocamlmktop / toplevels From: Gerd Stolpmann To: Richard Jones Cc: caml-list@inria.fr In-Reply-To: <20050812152827.GA4162@furbychan.cocan.org> References: <20050812152827.GA4162@furbychan.cocan.org> Content-Type: text/plain Date: Mon, 15 Aug 2005 15:35:21 +0200 Message-Id: <1124112922.12041.26.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at nez-perce with ID 43009A1D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43009A1B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlmktop:01 toplevels:01 gerd:01 stolpmann:01 toplevel:01 toplevel:01 toplevels:01 findlib:01 ocamlfind:01 ocamlmktop:01 -custom:01 -package:01 findlib:01 -linkpkg:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Am Freitag, den 12.08.2005, 16:28 +0100 schrieb Richard Jones: > I'm experimenting with building a custom toplevel, but have run across > some problems. > > (1) I want to have some modules 'open' already in the toplevel - we > have lots and lots of modules, some with long names, and most of these > should be opened by default. The partial solution is to add lots of > 'open' statements to a .ocamlinit file in the current directory, but > this assumes that you know what the current directory is, and that you > only need to use one type of toplevel in that directory. It is not possible to compile such "open"s into the toplevels. This has to to with the initialisation order. Nevertheless, a partial solution is implemented in findlib: ocamlfind ocamlmktop -o top -custom -package findlib,... -linkpkg Note that I mention "findlib" explicitly. Now you can at least #require the packages in scripts which generates the necessary #directory directives, so your script becomes independent of where the packages are actually installed. (#require does not load code that is already part of the toplevel.) My advice is to have a project-wide initialisation file one can #use from the scripts, e.g. #!./top #use "./init.ml" And in init.ml there are all the #require and open directives. > (2) Toplevels don't work the same way as 'ocaml'. The difference is > that our custom toplevel ignores any command line arguments passed to > it, whereas 'ocaml foo.ml' runs 'foo.ml'. This means that we can't > use our toplevel to write scripts: > > #!./adwords > > (or variations we've tried) doesn't work. For me this works. Maybe the OS does not resolve the relative path. You can also try #! /usr/bin/env ./adwords but note that #! only allows one argument. > (3) Some libraries are linked into the toplevel, but apparently can't > be accessed. For instance, Calendar ExtLib must be linked into the > toplevel because our main code relies on them; however no symbols from > either are visible: > > $ ./adwords > Objective Caml version 3.08.2 > > # Date.today ();; > Unbound value Date.today > # open Date;; > Unbound module Date > # ExtString.String.split;; > Unbound value ExtString.String.split The directories are not in the search path. This is solved by the #require trick shown above. > > Rich. > > PS. This is how we build the toplevel: > > ocamlfind ocamlmktop -custom -package pxp-lex-iso88591,pxp-engine,netclient,netstring,extlib,pcre,calendar -I ../ocsoap -I ../csv -linkpkg ../ocsoap/oCSoap.cmo ../csv/csv.cma adwords.cma -o adwords > Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Telefon: 06151/153855 Telefax: 06151/997714 ------------------------------------------------------------