caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Calling the toplevel from the toplevel
@ 2011-02-26 21:44 rixed
  2011-02-27  2:45 ` Guillaume Yziquel
  2011-02-27 12:00 ` Jérémie Dimino
  0 siblings, 2 replies; 8+ messages in thread
From: rixed @ 2011-02-26 21:44 UTC (permalink / raw)
  To: caml-list

I'm trying to build an application that's run from the toplevel, using
the toplevel to customize the application from itself (for instance,
setting some global parameters using the toplevel to configure the
application behavior while it's running).

But I cannot allow the toplevel to read directly from stdin nor to
write anything into stdout (since my application uses ncurses).

I've looked for various ways to do this, and the simpler I found to
prevent the toplevel to use stdout is to call myself
Toploop.execute_phrase with a custom formatter (so that I can display
the output where and how I want).

Up to now all seams to work except for minor annoyances :

- I cannot start the application directly by linking the custom toplevel
  with something like "let _ = start_application ()" but I have to call
  "start_application();;" from the toplevel manually (or from the
  .ocamlinit file), otherwise the application bindings are not
  available.

- I cannot let the user uses the toplevel directives "use" and "load"
  because both writes into stdout whatever the formatter passed to
  Toploop.execute_phrase (for "use" this is easily solvable by shadowing
  the toplevel implementation by another one that call Toploop.use_file
  with my own formatter, but for "load" I would have to copy a lot of
  code from topdirs.ml

I'd like to know if it is safe to call the Toploop evaluation functions
from code evaluated from the toplevel itself ? Or if someone can suggest
a better way to prevent the toplevel from using stdout ?


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-03-03 18:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-26 21:44 [Caml-list] Calling the toplevel from the toplevel rixed
2011-02-27  2:45 ` Guillaume Yziquel
2011-02-27 10:52   ` rixed
2011-02-27 12:00 ` Jérémie Dimino
2011-02-28 18:28   ` rixed
2011-02-28 20:30     ` Jérémie Dimino
2011-02-28 21:14       ` Yoann Padioleau
2011-03-03 18:34   ` rixed

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