caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Michael Grünewald" <michipili@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Toplevel startup hook
Date: Sun, 13 Jul 2014 12:23:28 +0200	[thread overview]
Message-ID: <53C25E20.6070704@gmail.com> (raw)

When preparing a custom toplevel, one can use
Toploop.toplevel_startup_hook to prepare the environment of the
toplevel.  I use this to open some modules and add some custom printers.

It works great but I noticed a surprising behaviour.  When running, the
startup hook is executed before the input is read

   $ ./customtoplevel < script.ml

however with

  $ ./customtoplevel script.ml

or

  $ ./customtoplevel -stdin < script.ml

the startup hook is still executed, but apparently, it is executed
*after* script.ml, which makes the startup hook useless in this case,
since script.ml obviously wants to use the modules compiled in the
toplevel, which is only possible if the path of the interface is added
with a `#directory` directive.

What is the rationale behind this behaviour?  What is the best way to go
around this?  I am looking forward writing a toplevel which can open
modules and install printers. Is there a way to do this without relying
on initialisation files, i.e. purely “within” the executable produced by
ocamlmktop?

Also, is there any reason why CMI files not packed in the toplevel
together with the implementation?  It seems to me, one cannot use the
toplevel without these implementation files *and* there is no easy way
to let the toplevel find these files when you are working as a toplevel
developer (CMIs are in your project directories) and when you are
working as a toplevel user (CMIs are installed in the standard library
directory).
-- 
Michael


                 reply	other threads:[~2014-07-13 10:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=53C25E20.6070704@gmail.com \
    --to=michipili@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;
as well as URLs for NNTP newsgroup(s).