From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 96AFABB9C for ; Fri, 20 Jan 2006 15:40:29 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KEeSN1017809 for ; Fri, 20 Jan 2006 15:40:29 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA28362 for ; Fri, 20 Jan 2006 15:40:28 +0100 (MET) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KEeRx3017799 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Fri, 20 Jan 2006 15:40:28 +0100 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1EzxR2-0003My-Ks for caml-list@inria.fr; Fri, 20 Jan 2006 15:40:16 +0100 Received: from pps-gw.pps.jussieu.fr ([134.157.168.126]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jan 2006 15:40:16 +0100 Received: from code17 by pps-gw.pps.jussieu.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jan 2006 15:40:16 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: code17 Subject: Re: toplevel with pre-installed printers Date: Fri, 20 Jan 2006 15:13:38 +0100 Message-ID: <87wtgvng19.fsf@gmail.com> References: <43CFBE3E.1090808@andrej.com> <43CFC776.3060801@andrej.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pps-gw.pps.jussieu.fr User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/23.0.0 (gnu/linux) Cancel-Lock: sha1:hBL7d/WnoZn7kMI9tLsMQ5ginU0= Sender: news X-j-chkmail-Score: MSGID : 43D0F65B.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 43D0F65C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43D0F65B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; toplevel:01 andrej:01 andrej:01 toplevel:01 toplevels:01 statically:01 ocamlmktop:01 beginner's:01 ocaml:01 bigarray:01 bigarray:01 genarray:01 ocaml:01 3.09.0:01 genarray: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.5 required=5.0 tests=FROM_ENDS_IN_NUMS autolearn=disabled version=3.0.3 Andrej Bauer writes: > Sorry, I was not clear enough. I know about .ocamlinit. I am going to > have several custom ocamltop's and they can't all share the same > .ocamlinit. What now? I recently worked on a problem about customized toplevel. I need a generic toplevel with various kinds of preloaded modules and open them beforehand. So I can't produce these toplevels statically using ocamlmktop, I have to launch them with various configurations on the fly. Maybe this is also your situation. Here are some results I've got (especially from the beginner's list, hi Richard Jones :-) Case 1: Suppose your requirement is quite simple: pre-load variant modules, open them, execute some evaluations and primitives without showing the feedback ... and you don't have to do complex interpretation between the user input as well as feedback from the real ocaml toplevel. You would probably like to use the undocumented(why?) option "-init", then wrap your executable as a shell script or programs. Use it like the default .ocamlinit except now you can indicate who is the script for initialization. E.g. tmp/init.ml: # load "bigarray.cma";; open Bigarray.Genarray;; (* You may even delete it after execution, maybe dangerous *) Sys.command "rm tmp/init.ml";; ocaml -init tmp/init.ml Objective Caml version 3.09.0 # create;; - : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int array -> ('a, 'b, 'c) Bigarray.Genarray.t = # Obviously you can have different configuration for different toplevels you want, and even produce the configuration on the fly. Case 2: If you want to do complex interpretation between your user and the real ocaml toplevel, e.g. you want "My own topleve" instead of "Objective Caml version 3.09" showing at the beginning, you want to interpret the user's input secretly before feeding them to the toplevel (maybe camlp4 help to do anything possible here?) and hide or modify feedback from ocaml (maybe personalized pretty printer can solve any problem here?). Either you are quite familiar with toplevel source and hack by yourself, or like me really provide a program acting as translator, i.e. another process active between user and the background running toplevel. Then you can do anything as you want. I've done so, and wish to provide some of the generic functionality as library when I've got time to clean my code. Wish it helps! code17