Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: code17 <code17@gmail.com>
To: caml-list@inria.fr
Subject: Re: toplevel with pre-installed printers
Date: Fri, 20 Jan 2006 15:13:38 +0100	[thread overview]
Message-ID: <87wtgvng19.fsf@gmail.com> (raw)
In-Reply-To: <43CFC776.3060801@andrej.com>


Andrej Bauer <Andrej.Bauer@andrej.com> 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.
  
  <code>
  tmp/init.ml:

  # load "bigarray.cma";;
  open Bigarray.Genarray;;
  (* You may even delete it after execution, maybe dangerous *)
  Sys.command "rm tmp/init.ml";;
  </code>

  <command>
  ocaml -init tmp/init.ml
  </command>

  <toplevel>
            Objective Caml version 3.09.0

  # create;;
  - : ('a, 'b) Bigarray.kind ->
      'c Bigarray.layout -> int array -> ('a, 'b, 'c) Bigarray.Genarray.t
  = <fun>
  # 
  </toplevel>

  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




  parent reply	other threads:[~2006-01-20 14:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-19 16:28 Andrej Bauer
2006-01-19 16:53 ` [Caml-list] " Daniel Bünzli
2006-01-19 16:57 ` Eric Stokes
2006-01-19 17:08   ` Andrej Bauer
2006-01-19 17:49     ` Richard Jones
2006-01-19 19:12       ` Eric Cooper
2006-01-19 20:18         ` Richard Jones
2006-01-20  2:24           ` skaller
2006-01-20 16:49             ` David Brown
2006-01-20 19:29               ` skaller
2006-01-20 14:13     ` code17 [this message]
2006-01-20  8:29 ` Jean-Christophe Filliatre
2006-01-20 13:13   ` Gerd Stolpmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wtgvng19.fsf@gmail.com \
    --to=code17@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox