caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] a simple example of compiler-libs.toplevel?
@ 2021-03-05  5:05 Kenichi Asai
  2021-03-05  9:44 ` Jeremie Dimino
  0 siblings, 1 reply; 4+ messages in thread
From: Kenichi Asai @ 2021-03-05  5:05 UTC (permalink / raw)
  To: caml-list

Is there a simple (but complete) example that uses
compiler-libs.toplevel, like creating an OCaml toplevel that uses a
different character for a prompt?  When I tried:

- copy toplevel/topstart.ml to my_topstart.ml and change Topmain in it
  to My_topmain
- copy toplevel/topmain.ml to my_topmain.ml and change Toploop in it
  to My_toploop
- copy toplevel/toploop.ml to my_toploop.ml and change the prompt
  character in it
- optionally, copy toplevel/topdirs.ml to my_topdirs.ml and change
  Toploop, etc., to My_toploop (this does not affect the story below)

I ran into the following error:

The ocamltoplevel.cma library from compiler-libs cannot be loaded
inside the OCaml toplevel

When I disable it (by removing the expression that raises this error
in my_toploop.ml), I can launch the new toplevel, but I cannot define
a new name:

let a = 3

results in "Fatal error: a unbound at toplevel".  Is it possible to do
this kind of creating a new OCaml toplevel using compiler-libs.toplevel?
Or is the compiler-libs.toplevel intended for something else?

A bit of background.  I am developing an OCaml type debugger:

http://pllab.is.ocha.ac.jp/~asai/TypeDebugger/

and am currently trying to port it to a newer version of OCaml.  For
the current type debugger, I inserted code for type debugging into the
main loop in toploop.ml.  However, inserting code directly into the
OCaml source requires me to recompile whole (or at least the core of)
the OCaml.  If I could do the same with compiler-libs, that would be
great.

Any help is welcome.  (I also welcome the negative information saying
that it is impossible to do this kind of thing.  Then, I would fall
back to the old way of compiling whole the OCaml.)

Thank you in advance.

Sincerely,

-- 
Kenichi Asai

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

end of thread, other threads:[~2021-03-05 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05  5:05 [Caml-list] a simple example of compiler-libs.toplevel? Kenichi Asai
2021-03-05  9:44 ` Jeremie Dimino
2021-03-05 14:03   ` Kenichi Asai
2021-03-05 17:11     ` Jeremie Dimino

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