caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Toplevel startup hook
@ 2014-07-13 10:23 Michael Grünewald
  0 siblings, 0 replies; only message in thread
From: Michael Grünewald @ 2014-07-13 10:23 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-13 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-13 10:23 [Caml-list] Toplevel startup hook Michael Grünewald

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).